https://bugs.llvm.org/show_bug.cgi?id=40988
Bug ID: 40988
Summary: decltype resolution doesn't terminate recursion
Product: clang
Version: 8.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangb...@nondot.org
Reporter: simon.rich...@hogyros.de
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@metafoo.co.uk
GCC exhibits the same bug, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89563
I'm trying to build a commutative operator+ for a class, as a freestanding
template operator+ that accepts my class on the right hand side and reverses
the argument order:
struct one {};
struct two
{
two() { }
two(one const &) { }
operator one() const { return one{}; }
two operator+(one const &) const { return two{}; }
};
two operator+(two const &, two const &) { return two{}; }
template<typename T>
auto operator+(T const &lhs, two const &rhs) -> decltype(rhs + lhs)
{
return rhs + lhs;
}
void test()
{
one o;
two t;
auto a = o + t;
}
This fails to compile, because the decltype for the return type is resolved
recursively through the template, even though a nontemplate function exists.
This remains the case even if I make a freestanding operator+(two const &, one
const &);
icc and MSVC compile this code correctly.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs