https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111056
Bug ID: 111056
Summary: Missing -Wsign-compare warning with enum values
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: alexhenrie24 at gmail dot com
Target Milestone: ---
#include <stdio.h>
int main()
{
signed int a = 1;
enum : signed int { b = 1 };
unsigned int c = -1;
if (a < c) // condition is true, -Wsign-compare warns about it
puts("a < c");
if (b < c) // condition is true, but no warning
puts("b < c");
return 0;
}
The compiler should warn about both if statements.
$ gcc --version
gcc (GCC) 13.2.1 20230801