<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 crashes when std::visit is called with a lambda with trailing return type that requires messy name lookup"
   href="https://bugs.llvm.org/show_bug.cgi?id=47590">47590</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang crashes when std::visit  is called with a lambda with trailing return type that requires messy name lookup
          </td>
        </tr>

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

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

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

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rileylevy95@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>Created <span class=""><a href="attachment.cgi?id=23986" name="attach_23986" title="The repro.cpp file, the repro.ii file, and clang's stderr output pasted into one file, separated by headers with ==============s">attachment 23986</a> <a href="attachment.cgi?id=23986&action=edit" title="The repro.cpp file, the repro.ii file, and clang's stderr output pasted into one file, separated by headers with ==============s">[details]</a></span>
The repro.cpp file, the repro.ii file, and clang's stderr output pasted into
one file, separated by headers with ==============s

Suppose you have a few types with a free function defined on each of them. You
might want to define an overload that accepts a std::variant of these types and
calls std::visit to choose the appropriate behavior at runtime, perhaps using a
LIFT macro to pass the whole overload set to std::visit. 

But the name lookup in the trailing type ->decltype(the_function(...)) crashes
clang sometimes. 

I'm attaching an example where this happened. 

I'm running clang 10 on Linux as installed by my package manager, but the same
problem occurred on godbolt using trunk: <a href="https://godbolt.org/z/xa7oEY">https://godbolt.org/z/xa7oEY</a>

I ran it with  
$ clang++ -std=c++20 repro.cpp</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>