https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111056

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
We don't warn for the same reason as we don't warn for `constexpr` because the
value is known at compile time.
That is:
```
#include <stdio.h>

int main()
{
    signed int a = 1;
    enum : signed int { b = 1 }d = b;
    constexpr int t = 1;

    unsigned int c = -1;

    if (a < c) // condition is true, -Wsign-compare warns about it
        puts("a < c");

    if (t < c) // condition is true, but no warning
        puts("t < c");

    if (b < c) // condition is true, but no warning
        puts("b < c");

    if (d < c) // condition is true, -Wsign-compare warns about it
        puts("d < c");

    return 0;
}
```
`t` and `b` here are replaced with 1. But with a variable that is declared as
the enum type we do warn.

I think this is correct behavior really.
clang has the same behavior (well they don't yet support constexpr though).

Reply via email to