<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 - Nesting variant breaks template instantiation when valid constructor should exist"
   href="https://bugs.llvm.org/show_bug.cgi?id=43020">43020</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Nesting variant breaks template instantiation when valid constructor should exist
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.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>All Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>David.Truby@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22383" name="attach_22383" title="File believed to be valid that breaks with libc++ 9">attachment 22383</a> <a href="attachment.cgi?id=22383&action=edit" title="File believed to be valid that breaks with libc++ 9">[details]</a></span>
File believed to be valid that breaks with libc++ 9

It appears that when nesting variants sometimes a valid constructor doesn't get
chosen.
I've attached a file that builds with libc++ 8 but fails to build with libc++
9. In the attached file, I believe the very outermost variant should just be
initialised with A as the chosen alternative type. However what actually
happens is it attempts to initialise the class inside the nested variant, which
fails as there's no valid constructor. Incidentally it doesn't appear to matter
what the other types are, e.g. the outermost variant can be
std::variant<std::tuple<B>, A> or std::variant<std::optional<B>, A> and the
same template error still occurs.

I've narrowed the change down to this commit implementing P0608R3:
<a href="https://reviews.llvm.org/D44865">https://reviews.llvm.org/D44865</a>. I don't believe that the paper forbids what
this file does; I've added a line in the file showing that the initialisation I
think should be performed satisfies the added condition in the paper. The file
also compiles with gcc trunk and libstdc++, which also implements the same
paper, but doesn't compile with the same gcc and libc++ (it also doesn't build
with clang+libstdc++ trunk but I believe that's a separate issue as the error
is different).</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>