473,323 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

STL vector core dump

My application is built on sun solaris 9.0. 5.9 Generic_118558-26
sun4u sparc SUNW,Sun-Fire-V210

compiler : Sun C++ 5.5 Patch 113817-14 2005/07/19

I am creating a vector of int at the beginning of my application
(before the application does anything) and copying it to another
vector . my application segmentation faults!!!

std::vector<intv1;
std::vector<intv2 =v1;

The code works fine when the vector v1 is not empty.
std::vector<intv1;
v1.push_back(10);
std::vector<intv2 =v1;

Even the below code worked
std::vector<intv1(1);
std::vector<intv2 =v1;

I looked at the copy constructor for the vector and it does not seem
to be
checking for zero size.

Can anyone please explain why and also how to solve the problem
becuase i have several functions in my application that return a
vector (when a vector is returned , the copy constructor is called)
and the vector can be empty.

Thanks,
- Akila.

Apr 24 '07 #1
4 3181
Akila wrote:
My application is built on sun solaris 9.0. 5.9 Generic_118558-26
sun4u sparc SUNW,Sun-Fire-V210

compiler : Sun C++ 5.5 Patch 113817-14 2005/07/19

I am creating a vector of int at the beginning of my application
(before the application does anything) and copying it to another
vector . my application segmentation faults!!!

std::vector<intv1;
std::vector<intv2 =v1;
If your example is:
#include <vector>

int main()
{

std::vector<intv1;
std::vector<intv2 =v1;
}

then, it works without seg fault with gcc 4.1.2 on Linux machine.
Otherwise, I have no idea what you did

Can anyone please explain why and also how to solve the problem
becuase i have several functions in my application that return a
vector (when a vector is returned , the copy constructor is called)
and the vector can be empty.
Have you tried updating your compiler? Looks like it has some issues
Apr 24 '07 #2
Akila wrote:
My application is built on sun solaris 9.0. 5.9 Generic_118558-26
sun4u sparc SUNW,Sun-Fire-V210

compiler : Sun C++ 5.5 Patch 113817-14 2005/07/19

I am creating a vector of int at the beginning of my application
(before the application does anything) and copying it to another
vector . my application segmentation faults!!!
Lucky you, this is addressed in the FAQ:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
Apr 24 '07 #3
On Apr 24, 3:42 pm, Akila <cakilandesw...@gmail.comwrote:
My application is built on sun solaris 9.0. 5.9 Generic_118558-26
sun4u sparc SUNW,Sun-Fire-V210
compiler : Sun C++ 5.5 Patch 113817-14 2005/07/19
I am creating a vector of int at the beginning of my application
(before the application does anything) and copying it to another
vector . my application segmentation faults!!!
std::vector<intv1;
std::vector<intv2 =v1;
The code works fine when the vector v1 is not empty.
std::vector<intv1;
v1.push_back(10);
std::vector<intv2 =v1;
Even the below code worked
std::vector<intv1(1);
std::vector<intv2 =v1;
I looked at the copy constructor for the vector and it does
not seem to be checking for zero size.
Can anyone please explain why and also how to solve the problem
becuase i have several functions in my application that return a
vector (when a vector is returned , the copy constructor is called)
and the vector can be empty.
There must be something else you're doing wrong. I can't
reproduce the problem, and I tried with all three versions of
Sun CC I have handy: 5.1, 5.5 and 5.8 (both with
-library=stlport4 and without). Could you please post a minimum
example that reproduces the problem.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 26 '07 #4
On Apr 24, 3:42 pm, Akila <cakilandesw...@gmail.comwrote:
My application is built on sun solaris 9.0. 5.9 Generic_118558-26
sun4u sparc SUNW,Sun-Fire-V210
compiler : Sun C++ 5.5 Patch 113817-14 2005/07/19
I am creating a vector of int at the beginning of my application
(before the application does anything) and copying it to another
vector . my application segmentation faults!!!
std::vector<intv1;
std::vector<intv2 =v1;
The code works fine when the vector v1 is not empty.
std::vector<intv1;
v1.push_back(10);
std::vector<intv2 =v1;
Even the below code worked
std::vector<intv1(1);
std::vector<intv2 =v1;
I looked at the copy constructor for the vector and it does
not seem to be checking for zero size.
Can anyone please explain why and also how to solve the problem
becuase i have several functions in my application that return a
vector (when a vector is returned , the copy constructor is called)
and the vector can be empty.
There must be something else you're doing wrong. I can't
reproduce the problem, and I tried with all three versions of
Sun CC I have handy: 5.1, 5.5 and 5.8 (both with
-library=stlport4 and without). Could you please post a minimum
example that reproduces the problem.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ganesh Gella | last post by:
Hi All, I am using g++ on Linux, and my code has lot of vectors each stores a particualr type of structure. (Structure internally had some vectors). When I am trying to push_back an element to...
12
by: Gaurav | last post by:
Hello I have a program that basically inverts the contents of files except first line. It compiles fine but gives me core dump on running. If i comment temp.clear() it runs fine, but i need...
10
by: John Liu | last post by:
We upgraded from 7.2 to 7.4, it looks like everything working, but when I issue a query such as select * from tab (tab has about 2-3 million records), it causes core dump. I tuned some the...
3
by: John Liu | last post by:
AIX pg version 7.4 Select * from document2 core dump. Did a few more experiments with select * from document2 limit... I limit to 500000 it works, 600000 it exits but says "calloc:...
7
by: Rylan | last post by:
I'm writing a program that uses a vector of classes for storing information from a file. Unfortunately, my program causes a core dump upon attempting to add a second item to the vector. Any...
10
by: wong_powah | last post by:
I want to find out where (which line) my C program core dump. How to do that? Is there a web site describing the procedure? One approach is to use stack trace of the mdb debugger, but I does not...
1
by: simon | last post by:
I am having problem with an application which core dumps while deleting a vector here is the snippet : Event_Node_t struct defined in the header : +++++++++++++++++++++++++++++++++++++...
18
by: John Salmon | last post by:
I was under the impression that the following was always valid: std::vector<Tv; .. T *p = &(v); But I was recently told that care was needed in case the vector was empty, i.e., when v.size()...
6
by: Andy | last post by:
Hi all, I started developing a little app on my Mac using XCode some month ago. The app is running fine on my mac like a sharm. Now I am nearly ready and yesterday I moved the whole source code...
2
by: creativeinspiration | last post by:
Hey everybody. I have an issue where pushing a new item onto an STL vector, I get a core dump. Now, the capacity of the vector is not exceeded (its only 3). The vector contains integers. Now, in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.