https://bugs.llvm.org/show_bug.cgi?id=43090
Bug ID: 43090
Summary: self reference function variable cannot deduce auto
return type
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: release blocker
Priority: P
Component: C++17
Assignee: unassignedclangb...@nondot.org
Reporter: adrianh....@gmail.com
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk
This appears to be a bug. The following sample doesn't compile under LLVM but
does under gcc and msvc:
-----8<--------------------8<---------------
#define USE_TEMPLATE 0
#if USE_TEMPLATE
template <typename I>
constexpr auto fn(I i)
#else
auto fn = [](auto i) constexpr
#endif
{
if constexpr (i() == 0)
return fn([i]{return i() + 1;});
else
return 1;
};
int main()
{
return fn([]{ return 0;});
}
---------------->8-------------------->8----
It give the following error:
<source>:14:16: error: variable 'fn' declared with deduced type 'auto' cannot
appear in its own initializer
return fn([i]{return i() + 1;});
^
See https://godbolt.org/z/58VELd for demo.
--
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