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

            Bug ID: 45158
           Summary: __is_constructible intrinsic does not SFINAE on
                    default member initializers
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: alisda...@me.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

The various standard type traits querying whether a type is constructible are
implemented (in both libc++ and libstdc++) as ultimately delegating to an
intrinsic such as __is_constructible.  This trait fails to account for default
member initializers, which produce a hard error rather than returning a
true/false answer when evaluating the intrinsic, and hence the trait.

Example:

#include <type_traits>

template <class T>
struct Wrap {
    Wrap() = default;

    T data{};    // default member initializer
};

struct NoDefault {
    NoDefault(NoDefault const&) {}  // non-trivial, not an aggregate
};

int main() {
    using namespace std;
    static_assert(!is_default_constructible<Wrap<NoDefault>>::value, "bad");
}


Godbolt link for quick experimentation: https://godbolt.org/z/-D9mpA

This fails with both libc++ and libstdc++, for all dialects of C++11 and later,
for all online compilers up to and including trunk.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to