<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 - Clang allows structured binding of a closure object inside its operator()"
   href="https://bugs.llvm.org/show_bug.cgi?id=41765">41765</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang allows structured binding of a closure object inside its operator()
          </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>Keywords</th>
          <td>accepts-invalid
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++'17
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>language.lawyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Since <a href="https://wg21.link/P0969R0">https://wg21.link/P0969R0</a> (implemented in [1]) structured binding of a
class does not rely on publicity of the members, only accessibility. So it is
possible to decompose a closure from the inside of its operator().

int main()
{
        int x = 1, y = 2;
        auto f = [&](auto self) {
                (void)x; (void)y; // make 'em used!
                auto& [a, b] = *self; // a == 1, b == 2. Depends on the
previous line.
                return b - a;
        };
        return f(&f); // returns 1
}

<a href="https://wandbox.org/permlink/CVlWjnDHPPMbRT2r">https://wandbox.org/permlink/CVlWjnDHPPMbRT2r</a>

[1]
<a href="https://github.com/llvm/llvm-project/commit/5c9b3b757623e6bea5b4929b2046a565ee2d11bc">https://github.com/llvm/llvm-project/commit/5c9b3b757623e6bea5b4929b2046a565ee2d11bc</a></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>