From: George K. <xke...@ne...> - 2012-08-29 22:05:50
|
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 <http://gcc.gnu.org/bugs.html> 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 |