public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46850] New: optimization of inline function leads to incorrect integer comparison result
@ 2010-12-08 15:31 brad.king at kitware dot com
  2010-12-08 15:35 ` [Bug c/46850] " rguenth at gcc dot gnu.org
  2010-12-08 15:57 ` brad.king at kitware dot com
  0 siblings, 2 replies; 3+ messages in thread
From: brad.king at kitware dot com @ 2010-12-08 15:31 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: optimization of inline function leads to incorrect
                    integer comparison result
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: brad.king@kitware.com


Created attachment 22686
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22686
Bash script to reproduce bug

The output of the attached script is expected to be "0" but is "1".
Tested on GCC 4.4.5, Linux x86_64, but I believe it occurs elsewhere too and in
other versions.

At first I encountered the problem with -O2 but then narrowed it down to

  -O -fstrict-overflow -foptimize-sibling-calls -ftree-vrp

as shown in the script.  Adding

  -fno-guess-branch-probability

fixes the problem.  Removing "inline" from the function fixes the problem.


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

* [Bug c/46850] optimization of inline function leads to incorrect integer comparison result
  2010-12-08 15:31 [Bug c/46850] New: optimization of inline function leads to incorrect integer comparison result brad.king at kitware dot com
@ 2010-12-08 15:35 ` rguenth at gcc dot gnu.org
  2010-12-08 15:57 ` brad.king at kitware dot com
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-12-08 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-12-08 15:35:41 UTC ---
You invoke undefined behavior by overflowing a signed integer.


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

* [Bug c/46850] optimization of inline function leads to incorrect integer comparison result
  2010-12-08 15:31 [Bug c/46850] New: optimization of inline function leads to incorrect integer comparison result brad.king at kitware dot com
  2010-12-08 15:35 ` [Bug c/46850] " rguenth at gcc dot gnu.org
@ 2010-12-08 15:57 ` brad.king at kitware dot com
  1 sibling, 0 replies; 3+ messages in thread
From: brad.king at kitware dot com @ 2010-12-08 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from brad.king at kitware dot com 2010-12-08 15:57:25 UTC ---
[smacks forehead]


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

end of thread, other threads:[~2010-12-08 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 15:31 [Bug c/46850] New: optimization of inline function leads to incorrect integer comparison result brad.king at kitware dot com
2010-12-08 15:35 ` [Bug c/46850] " rguenth at gcc dot gnu.org
2010-12-08 15:57 ` brad.king at kitware dot com

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).