https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105280
Bug ID: 105280 Summary: g++ does not raise sign-comapre in static_assert under some conditions Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cfy1990 at gmail dot com Target Milestone: --- g++ does not raise sign-compare warnings in static_assert((-1 >= 1u) && T1<T>::v, ""); Code link: https://godbolt.org/z/4GjT9f5oz Compile arguments: -O2 -std=c++11 -Wall -Wextra -Wconversion -Wsign-conversion -Wunused-result -Wsign-compare -Wlogical-not-parentheses -Wdouble-promotion Code: template<typename T> struct T1; template<> struct T1<unsigned int>{ const static bool v=true; }; template<typename T> void foo(__attribute__((unused)) T v){ // should generate warning, but not in g++ // clang works fine static_assert((-1 >= 1u) && T1<T>::v, ""); // codes works fine in gcc and clang static_assert((-1 >= 1u) && T1<unsigned>::v, ""); // sign-compare warning static_assert((-1 >= 1u), ""); // sign-compare warning constexpr bool b = (-1 >= 1u) && T1<T>::v; // sign-compare warning static_assert(b, ""); static_assert((!3 > -1) && T1<T>::v, ""); // logical-not-parentheses warning static_assert((1.0f*3.0 > 0) && T1<T>::v, ""); // double-promotion warning } void bar(){ static_assert((-1 >= 1u) && T1<unsigned int>::v, ""); // sign-compare warning foo(2u); }