public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27257]  New: Error integer compare in g++ 4.1.0
@ 2006-04-22  4:56 johnzhang at tencent dot com
  2006-04-22  8:23 ` [Bug c++/27257] " pluto at agmk dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: johnzhang at tencent dot com @ 2006-04-22  4:56 UTC (permalink / raw)
  To: gcc-bugs

0X80000000 - 10 < 0 and 10 - 0X80000000 < 0
gcc version 3.3.4 gets a right result of comparing between 10 and 0X80000000,
but gcc version 4.1.0 fails.

the test code followed:

#include <stdio.h>
int main()
{
        int b = 0X80000000;
        if ((10 -  b) < 0)
        {
                printf("(10 - b) = %d < 0 is True\n", 10 - b);
        }
        else
        {
                printf("(10 - b) = %d < 0 is False\n", 10 - b);
        }
        if ((b - 10) < 0)
        {
                printf("(b - 10) = %d < 0 is True\n", b - 10);
        }
        else
        {
                printf("(b - 10) = %d < 0 is False\n", b - 10);
        }

        return 0;
}

I had tested the code and got the result:
bingo@sttest:~/tmp> ../bin/g++ t.cpp
bingo@sttest:~/tmp> a.out
(10 - b) = -2147483638 < 0 is True
(b - 10) = 2147483638 < 0 is True


-- 
           Summary: Error integer compare in g++ 4.1.0
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: johnzhang at tencent dot com


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-15 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-22  4:56 [Bug c++/27257] New: Error integer compare in g++ 4.1.0 johnzhang at tencent dot com
2006-04-22  8:23 ` [Bug c++/27257] " pluto at agmk dot net
2006-04-22 15:35 ` pinskia at gcc dot gnu dot org
2006-04-28  6:36 ` johnzhang at tencent dot com
2006-04-28 16:29 ` pinskia at gcc dot gnu dot org
2007-01-15 20:04 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).