[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread gbuella at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #6 from Gábor Buella --- (In reply to Jonathan Wakely from comment #4) > I can't reproduce this with GCC 9, only 8. $ cat code.cc enum some_enum { x = 1000 }; void sink(some_enum); void func() { for (int i = 0; i < 3; ++i)

[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #5 from Richard Earnshaw --- I'm seeing it on AArch64 for master. Adding an enum value with an initializer of -1 causes the problem to go away. So it looks like the 'unsigned' conversion is happening too soon.

[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #4 from Jonathan Wakely --- I can't reproduce this with GCC 9, only 8.

[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread gbuella at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #3 from Gábor Buella --- In case anyone would still get confused about the what values get casted to enum, here is another way to write that example: enum some_enum { x0, x1, x2, x3, x4, x5, x6, x7, x8, x9,

[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread gbuella at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #2 from Gábor Buella --- (In reply to Andrew Pinski from comment #1) > -fstrict-enums > Allow the compiler to optimize using the assumption that a value of > enumerated type can only be one of the values of the enumeration (as defined

[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on

2020-02-11 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674 --- Comment #1 from Andrew Pinski --- -fstrict-enums Allow the compiler to optimize using the assumption that a value of enumerated type can only be one of the values of the enumeration (as defined in the C++ standard; basically, a value that can