llvm-project
llvm-project copied to clipboard
[clang] operator< parsed as template
The following fails to compile in clang unless there are parentheses around s.bazinga. gcc appears to accept this. Who is correct?
template <typename T>
struct bazinga {};
template <typename T>
struct Foo {
struct S { int bazinga; };
bool Bar(const S& s, int x) const {
return s.bazinga < x;
}
};
<source>:9:25: error: expected '>'
return s.bazinga < x;
^
<source>:9:22: note: to match this '<'
return s.bazinga < x;
^
<source>:9:25: error: expected unqualified-id
return s.bazinga < x;
^
2 errors generated.
Compiler Explorer: https://godbolt.org/z/oj86T3Taq
@llvm/issue-subscribers-clang-frontend
Clang is wrong here see basic.lookup.qual.general p2:
.. The lookup context of any other qualified name is the type, template, or namespace nominated by the preceding nested-name-specifier. ...
This a duplicate of: https://github.com/llvm/llvm-project/issues/59910