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

            Bug ID: 39686
           Summary: Union with variant member with non-trivial default
                    constructor but another variant member has a default
                    member initializer with deleted default constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangb...@nondot.org
          Reporter: yaghmour.sha...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Given the following code which is a more minimal example taken from this
Stackoveflow question https://stackoverflow.com/q/53310690/1708801

struct X {
  X() {}        //non-trivial default constructor
};

union U {
    X x;
    int i{};   //default member initializer
};

void foo() {
    U u;
}

clang gives the following diagnostic https://godbolt.org/z/6oTJ01 :

call to implicitly-deleted default constructor of 'U'
    U u;
      ^

note: default constructor of 'U' is implicitly deleted because variant field
'x' has a non-trivial default constructor
    X x;
      ^


but [class.default.ctor]p2 http://eel.is/c++draft/class.default.ctor#2.1 says:

  A defaulted default constructor for class X is defined as deleted if:
  - X is a union that has a variant member with a non-trivial default
constructor and no variant member of X has a default member initializer,

U does have a member with a default member initializer so the default
constructor should not be deleted and this should be well-formed.

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

Reply via email to