https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96675
Bug ID: 96675 Summary: tautological-compare warning emitted for NTTP bitwise comparison Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot uk Target Milestone: --- template<char c> constexpr bool f(char d) { return 'a' <= c && c <= 'z' ? (d | 0x20) == c : 'A' <= c && c <= 'Z' ? (d & ~0x20) == c : d == c; } static_assert(f<'p'>('P')); In instantiation of 'constexpr bool f(char) [with char c = 'p']': <source>:7:21: required from here <source>:4:44: warning: bitwise comparison always evaluates to false [-Wtautological-compare] 4 | 'A' <= c && c <= 'Z' ? (d & ~0x20) == c : | ~~~~~~~~~~~~^~~~ Per godbolt, this happened somewhere between 10.1.0 and 10.2.0. Motivation is https://github.com/capnproto/capnproto/commit/c38629e5a4b8ce9561b81cb23ea5fc39cbd93eb7