From: Brian Dessent <brian@dessent.net>
To: Alexey Neyman <stilor@att.net>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Bug with -ftree-vrp?
Date: Sun, 03 Aug 2008 00:26:00 -0000 [thread overview]
Message-ID: <4894FAFE.5982D164@dessent.net> (raw)
In-Reply-To: <200808021704.38246.stilor@att.net>
Alexey Neyman wrote:
> The problem is that with -O2, the second conditional gets optimized
> away. However, such optimization results in a misbehavior for the
> minimum number representable in 32 bits, 0x80000000. The option which
> triggers this optimization is -ftree-vrp.
Signed integer overflow is undefined in ISO C. If v = INT_MIN then v =
-v is undefined, and hence the compiler can assume this won't occur and
optimize away the test since a conformant program does not invoke
undefined behavior. Yes, there is some debate around the legitimacy of
this optimization because "traditional" C has more or less held that
signed integer overflow is perfectly defined on all two's compliment
machines (i.e. everywhere.) But the standard leaves it undefined and so
gcc is within its right to do this optimization, so say the language
lawyers.
You may be interested in the options -fno-strict-overflow, -fwrapv, and
-Wstrict-overflow.
Brian
prev parent reply other threads:[~2008-08-03 0:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-03 0:05 Alexey Neyman
2008-08-03 0:26 ` Brian Dessent [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4894FAFE.5982D164@dessent.net \
--to=brian@dessent.net \
--cc=gcc-help@gcc.gnu.org \
--cc=stilor@att.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).