[llvm-bugs] [Bug 46577] New: Operator overload resolution fails in fold expressions
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 3 05:56:45 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46577
Bug ID: 46577
Summary: Operator overload resolution fails in fold expressions
Product: clang
Version: 10.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: unassignedclangbugs at nondot.org
Reporter: micjabbour at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Given the following minimal example (which compiles successfully on GCC and
MSVC):
struct A {};
namespace detail {
// operator+ overload
A operator+(A, A) { return A{}; }
A f(A a) {
return a + a; // this works fine
}
template <typename... As> A g(As... as) {
// this however, fails to find operator+ when g is instantiated with "A"s
return (as + ... + A{});
}
}
int main() {
detail::f(A{}); // works
detail::g(A{}); // fails!
}
Clang gives the following error:
D:\ws> clang++ -std=c++17 prog.cc
prog.cc:11:16: error: call to function 'operator+' that is neither visible in
the template definition nor found by argument-dependent lookup
return (as + ... + A{});
^
prog.cc:17:11: note: in instantiation of function template specialization
'detail::g<A>' requested here
detail::g(A{}); // fails!
^
prog.cc:5:3: note: 'operator+' should be declared prior to the call site or in
the global namespace
A operator+(A, A) { return A{}; }
^
1 error generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200703/033d81ea/attachment.html>
More information about the llvm-bugs
mailing list