[LLVMbugs] [Bug 14123] New: union member with a user-declared, but not user-provided, trivial constructor implicitly deletes unions default constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 18 13:25:39 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14123

             Bug #: 14123
           Summary: union member with a user-declared, but not
                    user-provided, trivial constructor implicitly deletes
                    unions default constructor
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: seth.cantrell at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following valid code is rejected

// clang++ -std=c++11 test.cpp
union U {
struct S {
    S() = default;
} s;
} u;

error: call to implicitly-deleted default constructor of 'union U'
} u;
  ^
note: default constructor of 'U' is implicitly deleted because variant field
's' has a non-trivial default constructor
} s;
  ^

Clang incorrectly determines that the user declared (but not user provided)
constructor is non-trivial.

Interestingly, the following similar code is not rejected:

struct S {
    S() = default;
};

union U {
    S s;
} u;

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list