https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88434
Bug ID: 88434 Summary: operator< should take precedence over template argument in basic.lookup.classref Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gieseanw+gcc at gmail dot com Target Milestone: --- Semi-related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85570 Bug discovered here: https://stackoverflow.com/q/53712642/27678 The following code does not compile in gcc 9 (or earlier) or clang 8 (or earlier), but does in MSVC 19.00.23506. compile with -std=c++11 Code follows: #include <type_traits> using namespace std; struct A{ int rank; }; template<typename T> bool comp_rank(const T &a, const T &b){ return a.rank < b.rank; } int main() { A a{42}, b{0}; comp_rank(a, b); } gcc fails with prog.cc: In function 'bool comp_rank(const T&, const T&)': prog.cc:9:23: error: type/value mismatch at argument 1 in template parameter list for 'template<class> struct std::rank' 9 | return a.rank < b.rank; | ^~~~ prog.cc:9:23: note: expected a type, got 'b.rank' This appears to violate [basic.lookup.classref] which states In a class member access expression, if the . or -> token is immediately followed by an identifier followed by a <, the identifier must be looked up to determine whether the < is the beginning of a template argument list or a less-than operator. The identifier is first looked up in the class of the object expression. If the identifier is not found, it is then looked up in the context of the entire postfix-expression and shall name a class template.