[llvm-bugs] [Bug 34895] New: Poor interaction between std::tuple, std::pair of types with a std::any c'tor

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 9 17:06:42 PDT 2017


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

            Bug ID: 34895
           Summary: Poor interaction between std::tuple, std::pair of
                    types with a std::any c'tor
           Product: libc++
           Version: 5.0
          Hardware: PC
               URL: https://godbolt.org/g/mBbr5U
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dlj at google.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

Example:

https://godbolt.org/g/mBbr5U


    struct AnyOr {
        AnyOr();
        explicit AnyOr(const std::any& any_value);
    };
    std::tuple<AnyOr> t1; // OK
    std::tuple<std::any> t2{{}}; // OK
    std::tuple<AnyOr> t3{{}}; // ERROR
    std::tuple<AnyOr> t4{AnyOr{std::any{}}}; // ERROR


This seems to be fallout from https://reviews.llvm.org/rL276548 (a.k.a.
https://reviews.llvm.org/rL276548).

I believe the poor interaction is due to:

    template <class ValueType>
    any::any(ValueType&& value);

participating in:

    is_copy_assignable<AnyOr, const AnyOr&>

This is predicate is required by `std::tuple::tuple` (and `std::pair::pair`).

When `is_copy_assignable<AnyOr>` considers `AnyOr(const std::any&)`, the
specialization of the implicit conversion constructor `std::any::any<const
AnyOr&>` (i.e., [ValueType = const AnyOr&], [ValueType&& = const AnyOr&]) is
part of the overload set.

In turn, the `std::any::any(ValueType&&)` specialization requires
`std::is_copy_constructible<AnyOr>` (per 23.8.3.1p7:
https://timsong-cpp.github.io/cppwp/n4659/any#cons-7).

This is a circular dependency.


This seems to me like it may be a bug in the standard, but I'm filing for extra
eyes before escalating. The CE link includes GCC/libstdc++ and MSVC (GCC fails,
MSVC passes).

-- 
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/20171010/3153a2f8/attachment.html>


More information about the llvm-bugs mailing list