This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80299] New: No ordinary unqualified lookup for operators from default template arguments
- From: "kaballo86 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Apr 2017 01:31:31 +0000
- Subject: [Bug c++/80299] New: No ordinary unqualified lookup for operators from default template arguments
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80299
Bug ID: 80299
Summary: No ordinary unqualified lookup for operators from
default template arguments
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kaballo86 at hotmail dot com
Target Milestone: ---
The following snippet results in a compilation error:
struct X {};
namespace ns {
bool operator==(X const&, X const&);
template <typename T, typename R = decltype(T{} == T{})>
void check() {} // note: substitution failed, no 'operator=='
}
int main() {
ns::check<X>(); // error: no match
}
Unqualified lookup is not being done for `operator==`.
This other snippet further shows that the kind of lookups being done depends on
the context; within a default template argument only argument dependent lookup
is being done, while within the function template body unqualified lookup finds
a better match.
struct B {};
struct X : B {};
void operator==(B const&, B const&);
namespace ns {
bool operator==(X const&, X const&);
template <typename T, typename R = decltype(T{} == T{})>
void check(T v) {
decltype(T{} == T{}) rb = (v == v); // ok, bool
R rv = (v == v); // error, void
}
}
int main() {
X x;
ns::check(x);
}
Neither snippet fails if using function call syntax, `operator==(T{}, T{})`,
instead.