This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/26824] optimisation bug with -0x80000000



------- Comment #5 from simonmar at microsoft dot com  2006-03-23 15:10 -------
I see your point, but I still think there's a bug.  Let me change the code
slightly:

#include <stdlib.h>
#include <stdio.h>

void f(int x) {
    long y;
    if (x < 0) {
        y = -x;
        if (y > 0) {
            printf("%d\n",y);
        }
    }
}

int main() {
        f(-0x80000000);
        exit(0);
}

$ gcc -O2 foo.c
$ ./a.out      
-2147483648

so, we're in the y > 0 branch, but y is clearly < 0.


-- 

simonmar at microsoft dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|middle-end                  |c
         Resolution|INVALID                     |


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]