[llvm-bugs] [Bug 32766] New: Return type deduction for auto fails for member function in struct nested in lambda nested in function template
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 24 01:37:51 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32766
Bug ID: 32766
Summary: Return type deduction for auto fails for member
function in struct nested in lambda nested in function
template
Product: clang
Version: 4.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: arnetheduck at gmail.com
CC: llvm-bugs at lists.llvm.org
Here's a snippet which I *think* should compile (it does so with gcc/icc), but
fails under clang 4.0 - https://godbolt.org/g/8oCnrm
It works if any of the following are true:
* f is not a template function
* xxx is not a auto parameter
* v does not return auto
* R is not nested in y
template <typename F>
void f() {
auto y = [=] (auto xxx) {
struct R {
static constexpr auto v() { return 42; }
};
};
y(32);
}
void x() {
f<int>();
}
<source>:5:49: error: cannot initialize return object of type 'auto' with an
rvalue of type 'int'
static constexpr auto v() { return 42; }
^~
<source>:4:17: note: in instantiation of member function 'f()::(anonymous
class)::operator()(type-parameter-0-0)::R::v' requested here
struct R {
^
<source>:13:5: note: in instantiation of function template specialization
'f<int>' requested here
f<int>();
^
1 error generated.
Compiler exited with result code 1
The example looks a little convoluted but comes from real life in some
callback-heavy async code, deep down in a library.
--
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/20170424/c488f884/attachment-0001.html>
More information about the llvm-bugs
mailing list