[Bug c++/93674] GCC eliminates conditions it should not, when strict-enums is on
gbuella at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Feb 11 12:19:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93674
--- Comment #3 from Gábor Buella <gbuella at gmail dot com> ---
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, xa, xb, xc, xd, xe, xf,
x00, x01, x02, x03, x04, x05, x06, x07,
x08, x09, x0a, x0b, x0c, x0d, x0e, x0f };
void sink(some_enum);
void func()
{
for (int i = 0; i < 3; ++i) {
int j = 3;
while (j >= 0) {
// Note: (i + j) is always non-negative here
// Actually, (i + j) is always of the values
// given when defining the type above.
sink((some_enum)(i + j));
--j;
}
}
}
More information about the Gcc-bugs
mailing list