[Bug c++/41425] switch with enums doesn't work

2010-05-03 Thread jason at gcc dot gnu dot org
--- 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 --

[Bug c++/41425] switch with enums doesn't work

2009-09-22 Thread rguenth at gcc dot gnu dot org
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread Woebbeking at web dot de
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread paolo dot carlini at oracle dot com
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread schwab at linux-m68k dot org
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread rguenth at gcc dot gnu dot org
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread Woebbeking at web dot de
--- 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/

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread rguenth at gcc dot gnu dot org
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread paolo dot carlini at oracle dot com
-- paolo dot carlini at oracle dot com changed: What|Removed |Added Severity|critical|normal http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread paolo dot carlini at oracle dot com
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread Woebbeking at web dot de
-- Woebbeking at web dot de changed: What|Removed |Added Severity|normal |critical http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41425

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread Woebbeking at web dot de
--- 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

[Bug c++/41425] switch with enums doesn't work

2009-09-21 Thread Woebbeking at web dot de
--- 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