This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/30475] New: assert(int+100 > int) optimized away
- From: "felix-gcc at fefe dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jan 2007 19:43:02 -0000
- Subject: [Bug c/30475] New: assert(int+100 > int) optimized away
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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