[llvm-bugs] [Bug 45158] New: __is_constructible intrinsic does not SFINAE on default member initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 9 12:02:13 PDT 2020


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: unassignedclangbugs at nondot.org
          Reporter: alisdairm at me.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200309/b3b64b7a/attachment.html>


More information about the llvm-bugs mailing list