<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 - C++20 warning: template lambda "does not declare any constructor to initialize its non-modifiable members""
   href="https://bugs.llvm.org/show_bug.cgi?id=52322">52322</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>C++20 warning: template lambda "does not declare any constructor to initialize its non-modifiable members"
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jake.arkinstall@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In this toy code, clang 13 warns that a lambda function isn't initializing
captured members.

<a href="https://godbolt.org/z/hhszT4fqj">https://godbolt.org/z/hhszT4fqj</a>

I don't know whether (1) this is a false positive warning, (2) the warning is
legitimate and the generated code is incorrect, or (3) the code is truly
invalid and the warning is a side-effect of that.

I'm leaning towards #1. I'd rule #2 out because it still produces the correct
output, and I'd (tentatively) rule #3 out because GCC and MSVC don't see any
problems with the code (Clang 12 segfaults on it, which appears to be a parsing
issue).


<span class="quote">> <source>:9:48: warning: class '' does not declare any constructor to initialize its non-modifiable members
>             TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
>     ^
>         <source>:9:48: note: in instantiation of member class '' requested here
>                                    <source>:17:31: note: in instantiation of function template specialization 'TypeList<int, char>::max((lambda at <source>:34:9) &, (lambda at <source>:9:48) &&)::(anonymous class)::operator()<char>' requested here
>                                                                    callback.template operator()<head>();
>                               ^
> <source>:9:32: note: in instantiation of function template specialization 'TypeList<char>::max<(lambda at <source>:34:9) &, (lambda at <source>:9:48)>' requested here
>             TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
>                                ^
> <source>:9:32: note: in instantiation of function template specialization 'TypeList<int, char>::max<(lambda at <source>:34:9) &, (lambda at <source>:9:48)>' requested here
> <source>:33:11: note: in instantiation of function template specialization 'TypeList<long, int, char>::max<(lambda at <source>:34:9), (lambda at <source>:35:9)>' requested here
>     list::max(
>           ^
> <source>:9:50: note: reference member '' will never be initialized
>             TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {
>                                                  ^
> <source>:9:63: note: reference member '' will never be initialized
>             TypeList<tail...>::max(comparison, [&comparison, &callback]<typename S>() {</span ></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>