The small test program at http://ptrace.fefe.de/int.c illustrated the problem.
The assert is there to prevent integer overflow, which would not happen in my test program, but you get the idea. There appears to be something wrong with integer promotion here. The same code with int changed to unsigned int (http://ptrace.fefe.de/unsignedint.c) correctly fails the assertion at that point. My understanding of C integer promotion is that the 100 is an int unless anything else is said, so int+100 should still be an int, and so both sides should still be an int. Is that not correct? -- Summary: assert(int+100 > int) optimized away Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: felix-gcc at fefe dot de GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475