[llvm-bugs] [Bug 43020] New: Nesting variant breaks template instantiation when valid constructor should exist

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 16 09:25:01 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43020

            Bug ID: 43020
           Summary: Nesting variant breaks template instantiation when
                    valid constructor should exist
           Product: libc++
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: David.Truby at arm.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Created attachment 22383
  --> https://bugs.llvm.org/attachment.cgi?id=22383&action=edit
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:
https://reviews.llvm.org/D44865. 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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190816/cd4d73d2/attachment.html>


More information about the llvm-bugs mailing list