Thanks, I changed the function to use a pointer to my region object and the segmention fault was gone.

2012/8/29 George Koehler <>
This code (attached in Fail.cpp) reproduces the bug:

struct Region {
  int data[16][512][16];

struct Frog {
  void eat(Region);

void Frog::eat(Region reg) {

$ g++ -c Fail.cpp
Fail.cpp: In member function 'void Frog::eat(Region)':
Fail.cpp:10:1: internal compiler error: Segmentation fault

Please submit a full bug report,
with preprocessed source if appropriate.
See <> for instructions.

Notice that a Region is very large; 16 * 512 * 16 = 131072 ints, at 4 bytes per int, so 524288 bytes, around 500 kilobytes.  Each call to Frog::eat will pass a Region by value, copying around 500 kilobytes to construct another Region object.  Frog::eat keeps the Region in a local variable, and will construct the Region on the call stack. However, the system limits the call stack to some number of kilobytes.  Region might be too big.

One should always construct Region with the new operator (or with malloc, or so on) and pass it by reference (Region &) or as pointer (Region *).

I know not why g++ crashed.

--George Koehler

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
MinGW-users mailing list

This list observes the Etiquette found at
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at: