[llvm-bugs] [Bug 40988] New: decltype resolution doesn't terminate recursion
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 6 16:19:04 PST 2019
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: unassignedclangbugs at nondot.org
Reporter: Simon.Richter at hogyros.de
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190307/a4e500dd/attachment-0001.html>
More information about the llvm-bugs
mailing list