--- Comment #11 from jason at gcc dot gnu dot org 2010-05-04 04:48 ---
In G++ 4.6 the confusing optimization will only be performed with
-fstrict-enums.
--
jason at gcc dot gnu dot org changed:
What|Removed |Added
--
--- Comment #10 from rguenth at gcc dot gnu dot org 2009-09-22 11:43
---
Yes, as part of a wrong-code fix.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #9 from Woebbeking at web dot de 2009-09-21 16:46 ---
So it's ok to change the behavior in a minor release?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #8 from paolo dot carlini at oracle dot com 2009-09-21 14:45
---
Agreed, unspecified, as the actual citation says.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #7 from schwab at linux-m68k dot org 2009-09-21 14:25 ---
(In reply to comment #3)
> As far as I can see, you are triggering undefined behavior.
There is a big difference between undefined and unspecified behaviour. With
unspecified behaviour the implementation must chose a
--- Comment #6 from rguenth at gcc dot gnu dot org 2009-09-21 13:08 ---
Switch assembly is optimized if you handle all valid cases (which you do) into
if (i != 0)
case B
else
case A
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #5 from Woebbeking at web dot de 2009-09-21 12:53 ---
Paolo, but std::cout << static_cast(i); prints 5, so it's not the
conversion but the switch statement which is "broken".
Richard, if it's only truncation shouldn't case B be triggered?
--
http://gcc.gnu.org/bugzilla/
--- Comment #4 from rguenth at gcc dot gnu dot org 2009-09-21 12:44 ---
In C++ an enum type only has the minimum number of bits that is required to
store all its values, thus 1 in your case. So (foo)5 is a truncation.
--
rguenth at gcc dot gnu dot org changed:
What|R
--
paolo dot carlini at oracle dot com changed:
What|Removed |Added
Severity|critical|normal
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #3 from paolo dot carlini at oracle dot com 2009-09-21 12:41
---
As far as I can see, you are triggering undefined behavior. Per 5.2.9/7: "A
value of integral or enumeration type can be explicitly converted to an
enumeration type. The value is unchanged if the original value
--
Woebbeking at web dot de changed:
What|Removed |Added
Severity|normal |critical
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #2 from Woebbeking at web dot de 2009-09-21 12:21 ---
g++ case.cpp is sufficient to reproduce this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
--- Comment #1 from Woebbeking at web dot de 2009-09-21 12:19 ---
Created an attachment (id=18622)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18622&action=view)
testcase
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425
13 matches
Mail list logo