This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/41882] gcc bug when comparing x to -x (linux, 32-bit)
- From: "daven at model dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Oct 2009 22:28:10 -0000
- Subject: [Bug c/41882] gcc bug when comparing x to -x (linux, 32-bit)
- References: <bug-41882-18374@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from daven at model dot com 2009-10-30 22:28 -------
Subject: Re: gcc bug when comparing x to -x (linux, 32-bit)
Thanks for your quick response. I would like to point out that on every
compiler and machine
I've used, the behavior of signed overflow may not be defined -- but
it's always been consistent.
Perhaps the inline optimizations that are taking place could be made to
at least function the
same way as the non-inlined case? (Or am I going to get no-bugged on
this bugz?)
--David
rguenth at gcc dot gnu dot org wrote:
> ------- Comment #1 from rguenth at gcc dot gnu dot org 2009-10-30 22:23 -------
> signed overflow invokes undefined behavior. You can use -fwrapv to make it
> wrapping. Or you can use unsigned types for the comparison, like
>
> if ((unsigned)x != -(unsigned)x)
>
>
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41882