public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56652] New: Wrong code in O2 - if in inline function
@ 2013-03-18 12:03 dominik.siatkowski at aldec dot com.pl
2013-03-18 12:05 ` [Bug c++/56652] " dominik.siatkowski at aldec dot com.pl
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: dominik.siatkowski at aldec dot com.pl @ 2013-03-18 12:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
Bug #: 56652
Summary: Wrong code in O2 - if in inline function
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dominik.siatkowski@aldec.com.pl
Bug detected with gcc-4.7.2 on i386-linux-gnu
Attached example segfalts compiled with -O2 (or even with '-O1
-finline-small-functions -fstrict-overflow -ftree-vrp')
Works with -O1. Works also if compiled in one compilation unit.
Stepping thru code shows it enters
if (count >= 0 && count < size)
in shift_right, where count is INT_MIN and size is 2.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
@ 2013-03-18 12:05 ` dominik.siatkowski at aldec dot com.pl
2013-03-18 12:15 ` markus at trippelsdorf dot de
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: dominik.siatkowski at aldec dot com.pl @ 2013-03-18 12:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
--- Comment #1 from dominik.siatkowski at aldec dot com.pl 2013-03-18 12:05:05 UTC ---
Created attachment 29691
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29691
example
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
2013-03-18 12:05 ` [Bug c++/56652] " dominik.siatkowski at aldec dot com.pl
@ 2013-03-18 12:15 ` markus at trippelsdorf dot de
2013-03-18 12:16 ` dominik.siatkowski at aldec dot com.pl
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: markus at trippelsdorf dot de @ 2013-03-18 12:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
Markus Trippelsdorf <markus at trippelsdorf dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |markus at trippelsdorf dot
| |de
--- Comment #2 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2013-03-18 12:15:21 UTC ---
Quick check with clang -fsanitize=undefined shows:
...
numeric.cc:47:30: fatal error: negation of -2147483648 cannot be represented in
type 'int'; cast to an unsigned type to negate this value to itself
Thus invalid.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
2013-03-18 12:05 ` [Bug c++/56652] " dominik.siatkowski at aldec dot com.pl
2013-03-18 12:15 ` markus at trippelsdorf dot de
@ 2013-03-18 12:16 ` dominik.siatkowski at aldec dot com.pl
2013-03-18 12:24 ` dominik.siatkowski at aldec dot com.pl
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: dominik.siatkowski at aldec dot com.pl @ 2013-03-18 12:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
--- Comment #3 from dominik.siatkowski at aldec dot com.pl 2013-03-18 12:16:35 UTC ---
Is seems its 4.7 reggresion.
Example works if compiled with 4.6.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
` (2 preceding siblings ...)
2013-03-18 12:16 ` dominik.siatkowski at aldec dot com.pl
@ 2013-03-18 12:24 ` dominik.siatkowski at aldec dot com.pl
2013-03-18 12:34 ` markus at trippelsdorf dot de
2013-03-20 0:49 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: dominik.siatkowski at aldec dot com.pl @ 2013-03-18 12:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
--- Comment #4 from dominik.siatkowski at aldec dot com.pl 2013-03-18 12:24:17 UTC ---
(In reply to comment #2)
> Quick check with clang -fsanitize=undefined shows:
> ...
> numeric.cc:47:30: fatal error: negation of -2147483648 cannot be represented in
> type 'int'; cast to an unsigned type to negate this value to itself
>
> Thus invalid.
Thank you. OK, works if I change type of count and size to unsigned.
So INT_MIN has wrong value?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
` (3 preceding siblings ...)
2013-03-18 12:24 ` dominik.siatkowski at aldec dot com.pl
@ 2013-03-18 12:34 ` markus at trippelsdorf dot de
2013-03-20 0:49 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: markus at trippelsdorf dot de @ 2013-03-18 12:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
--- Comment #5 from Markus Trippelsdorf <markus at trippelsdorf dot de> 2013-03-18 12:33:50 UTC ---
(In reply to comment #4)
> (In reply to comment #2)
> > Quick check with clang -fsanitize=undefined shows:
> > ...
> > numeric.cc:47:30: fatal error: negation of -2147483648 cannot be represented in
> > type 'int'; cast to an unsigned type to negate this value to itself
> >
> > Thus invalid.
>
> Thank you. OK, works if I change type of count and size to unsigned.
> So INT_MIN has wrong value?
-INT_MIN is an integer overflow and is undefined behavior in C.
http://www.google.com/search?hl=en&q=+INT_MIN
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56652] Wrong code in O2 - if in inline function
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
` (4 preceding siblings ...)
2013-03-18 12:34 ` markus at trippelsdorf dot de
@ 2013-03-20 0:49 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-03-20 0:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56652
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
Severity|major |normal
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-03-20 00:49:45 UTC ---
Invalid, thanks, Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-20 0:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18 12:03 [Bug c++/56652] New: Wrong code in O2 - if in inline function dominik.siatkowski at aldec dot com.pl
2013-03-18 12:05 ` [Bug c++/56652] " dominik.siatkowski at aldec dot com.pl
2013-03-18 12:15 ` markus at trippelsdorf dot de
2013-03-18 12:16 ` dominik.siatkowski at aldec dot com.pl
2013-03-18 12:24 ` dominik.siatkowski at aldec dot com.pl
2013-03-18 12:34 ` markus at trippelsdorf dot de
2013-03-20 0:49 ` redi at gcc dot gnu.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).