The attached program causes an ICE when compiled with both -O and -ftrapv: $ g++ -O -ftrapv -c Linear_System.ii g++: Internal error: Segmentation fault (program cc1plus) Please submit a full bug report. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Created attachment 11274 [details] Testcase that allows to reproduce the problem
Reducing.
Confirmed. Reduced testcase (compile with "-O -ftrapv"): ================================== char *p, *q; inline int foo(int i) { return (p - q) + i; } void bar() { int n, i; for (n = 7; n-- > 0; ) for (i = n; i-- > 0; ) if (i) p += -foo(i-1); } ================================== The testcase eats more than 2 GB of memory within seconds. This happens with C and C++ frontend. The bug only affects the 4.0 branch.
The testcase in comment #3 only crashes on x86_64-unknown-linux-gnu, but not on i686-pc-linux-gnu. The testcase below crashes on both archs: =================================== char *p, *q; inline int foo(int i) { int j = (p - q) + i; return -j; } void bar() { int n, i; for (n = 7; n-- > 0; ) for (i = n; i-- > 0; ) if (i) p += foo(i-1); } ===================================
Fixed in GC-4.1.0.