[Bug libstdc++/103891] New: clang-13 fails to compile libstdc++'s std::variant<std::vector<int>>: error: attempt to use a deleted function

slyfox at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Jan 2 21:40:03 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103891

            Bug ID: 103891
           Summary: clang-13 fails to compile libstdc++'s
                    std::variant<std::vector<int>>: error: attempt to use
                    a deleted function
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Initially I observed the error as a mold-1.0.0 build failure on clang-13 which
uses gcc-12's libstdc++. Here is a one line reproducer:

    #include <variant>
    #include <vector>

    std::variant<std::vector<long> > v;

$ /tmp/gcc-12/bin/c++ -std=c++20 -c tapi.cc
$ /tmp/clang-13/bin/c++ -std=c++20 -c tapi.cc
/<<NIX>>/gcc-12.0.0/include/c++/12.0.0/variant:460:2: error: attempt to use a
deleted function
        _Variant_storage(in_place_index_t<_Np>, _Args&&... __args)
        ^
/<<NIX>>/gcc-12.0.0/include/c++/12.0.0/variant:747:4: note: in instantiation of
function template specialization
'std::__detail::__variant::_Variant_storage<false,
std::vector<long>>::_Variant_storage<0UL>' requested here
        : _Base(__i, std::forward<_Args>(__args)...)
          ^
/<<NIX>>/gcc-12.0.0/include/c++/12.0.0/variant:742:9: note: in instantiation of
function template specialization
'std::__detail::__variant::_Variant_base<std::vector<long>>::_Variant_base<0UL>'
requested here
      : _Variant_base(in_place_index<0>) { }
        ^
/<<NIX>>/gcc-12.0.0/include/c++/12.0.0/variant:1403:7: note: in instantiation
of member function
'std::__detail::__variant::_Variant_base<std::vector<long>>::_Variant_base'
requested here
      variant() = default;
      ^
...


I attempted to reduce it down to something manageable but ended up with
something else: https://github.com/llvm/llvm-project/issues/52956

I don't really understand how requires() works.

Should libstdc++ work as is against clang++? Does it perhaps need a small
tweak?

Thank you!


More information about the Gcc-bugs mailing list