[Bug c/35753] apparent integer math bug

pinskia at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Mar 29 05:09:00 GMT 2008



------- Comment #1 from pinskia at gmail dot com  2008-03-29 05:08 -------
Subject: Re:   New: apparent integer math bug



Sent from my iPhone

On Mar 28, 2008, at 21:40, "regehr at cs dot utah dot edu"
<gcc-bugzilla@gcc.gnu.org 
 > 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
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35753



More information about the Gcc-bugs mailing list