[llvm-bugs] [Bug 25880] New: std::is_default_constructible deletes default constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 18 03:37:04 PST 2015


            Bug ID: 25880
           Summary: std::is_default_constructible deletes default
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: juri.valdmann at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified


I've ran into an interesting issue, where, under certain circumstances,
evaluating std::is_default_constructible<T>::value has the unexpected
side-effect of seemingly deleting T's implicit default constructor.

Here is a minimized test case

    #include <type_traits>

    struct Helper
        Helper() {}
        // one of the following two is required
        Helper(const Helper &) {}
        Helper(Helper &&) {}

    struct Outer
        struct Inner
            int x = 0;

        Helper x;
        Inner y;

        Outer() {}

        // this has to be inside Outer (i.e. not global)
        static const bool delete_ctor_of_Inner =

    int main() {}

With both clang 3.6.2 and 3.7.0 the following error output is generated:

    $ clang -std=c++14 test.cpp

    test.cpp:21:5: error: constructor for 'Outer' must explicitly initialize
the member 'y' which does not have a default constructor
        Outer() {}
    test.cpp:19:11: note: member is declared here
        Inner y;
    test.cpp:13:12: note: 'Outer::Inner' declared here
        struct Inner
    1 error generated.

The libstdc++ is from GCC 4.9.2. With clang 3.5.0 it works.

Jüri Valdmann

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/20151218/b1faf3b3/attachment.html>

More information about the llvm-bugs mailing list