<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Return type deduction for auto fails for member function in struct nested in lambda nested in function template"
   href="https://bugs.llvm.org/show_bug.cgi?id=32766">32766</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Return type deduction for auto fails for member function in struct nested in lambda nested in function template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>arnetheduck@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Here's a snippet which I *think* should compile (it does so with gcc/icc), but
fails under clang 4.0 - <a href="https://godbolt.org/g/8oCnrm">https://godbolt.org/g/8oCnrm</a>

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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>