https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572
Bug ID: 66572 Summary: [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: miyuki at gcc dot gnu.org Target Milestone: --- Consider this example: $ cat ./test.cc struct false_type { static constexpr bool value = false; }; struct true_type { static constexpr bool value = true; }; template<typename T> struct is_unsigned : false_type {}; template<> struct is_unsigned<unsigned> : true_type {}; template<typename T1, typename T2> bool foo() { return is_unsigned<T1>::value && is_unsigned<T2>::value; } int main() { foo<unsigned, unsigned>(); } $ g++ -Wlogical-op -std=c++11 ./test.cc ./test.cc: In instantiation of 'bool foo() [with T1 = unsigned int; T2 = unsigned int]': ./test.cc:25:29: required from here ./test.cc:20:35: warning: logical 'and' of equal expressions [-Wlogical-op] return is_unsigned<T1>::value && is_unsigned<T2>::value; IMHO GCC should not issue this warning: in this instantiation (is_unsigned<unsigned>::value && is_unsigned<unsigned>::value) operator && is indeed redundant, but that is not true for general case.