This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Trouble with std::vector in g++


I am having some trouble with the std::vector class in g++ 3.3.3.  If I
compile the following program and run it, it segfaults in the call to
push_back; reducing the array in Solution to 512*1024 makes the code run
OK.

If I compile it with g++ 3.2.1 under Linux, the program runs fine.

Is it just my misunderstanding of how the STL works, or is there a
compiler/library problm here?

vvv begin code vvv

#include <vector>

class Solution {
public:
  char se[1024*1024];
};

class Element {
public:
  Solution s;
};

typedef std::vector<Element> element_list_t;

class Mesh {
public:
  element_list_t elements;
};

int
main()
{
  Mesh *mesh = new Mesh;

  Element el;

  mesh->elements.push_back(el);

  return 0;
}

^^^ end code sample ^^^

compile with:

$ g++ -Wall -o etest etest.cc
$ ./etest
Segmentation fault (core dumped)

-- 
Luke Stras <stras@utias.toronto.edu>
"The meek can have the Earth; the rest of us have other plans" 
  --Henry Spencer

Attachment: cygcheck.out
Description: Text document

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]