https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70181
Bug ID: 70181 Summary: missing -Wtautological-compare for constant expressions Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- According to the documentation for -Wtautological-compare: Warn if a self-comparison always evaluates to true or false. This warning detects various mistakes such as: ... all three equality expressions in the program below should be diagnosed, yet only the first on in function f() is. Clang diagnoses all three as expected. Either the other expressions should be diagnosed or the documentation clarified that the warning is deliberately not issued for constant expressions. $ cat v.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -o/dev/null -xc++ v.c int f (int i) { if (i == i) return 1; return 0; } enum { i = 0 }; const bool b0 = i == i; constexpr int j = 0; constexpr bool b1 = j == j; v.c: In function ‘int f(int)’: v.c:1:23: warning: self-comparison always evaluates to true [-Wtautological-compare] int f (int i) { if (i == i) return 1; return 0; } ~~^~~~