Sent from my iPhone
On Mar 28, 2008, at 21:40, "regehr at cs dot utah dot edu" <[EMAIL PROTECTED]
> wrote:
This is for "gcc (GCC) 4.3.0".
This function returns different values at -O1 and -O2:
int func_5 (void) {
int g_4 = 0x4E6D4F28;
return 0 <= (6 * g_4);
}
This multiplication overflows so the resulting behavior is undefined.
-- pinski
At -O1 output looks good:
func_5:
pushl %ebp
movl %esp, %ebp
movl $0, %eax
popl %ebp
ret
At -O2 not good:
func_5:
pushl %ebp
movl $1, %eax
movl %esp, %ebp
popl %ebp
ret
--
Summary: apparent integer math bug
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: regehr at cs dot utah dot edu
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35753