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

            Bug ID: 40555
           Summary: clang emits misleading diagnostic messages about copy
                    assignment operators when a class has a nested
                    anonymous union member
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

When the following code is compiled, the diagnostic message says the copy
assignment operator of the containing class is deleted because the variant
field has a non-trivial copy assignment operator instead of saying it has a
deleted copy assignment operator.

$ cat test.cpp
struct S0 {
  S0(const S0 &);
  S0 &operator=(const S0 &);
  int *p;
};

struct S1 {
  union {
    union { // copy assignment operator is deleted because of s10.
      S0 s10;
      int b;
    };
    int c;
  };
  ~S1();
};

S1 *x0;

void testC1(S1 *a0) {
  *a0 = *x0;
  *a0 = static_cast<S1&&>(*x0);
}

$ clang++ -std=c++11 -c test.cpp
test.cpp:21:7: error: object of type 'S1' cannot be assigned because its copy
      assignment operator is implicitly deleted
  *a0 = *x0; // error: object of type 'S1' cannot be assigned because it...
      ^
test.cpp:9:5: note: copy assignment operator of 'S1' is implicitly deleted
      because variant field '' has a non-trivial copy assignment operator
    union { // copy assignment operator of 'S1' is implicitly deleted bec...
    ^
test.cpp:22:7: error: object of type 'S1' cannot be assigned because its copy
      assignment operator is implicitly deleted
  *a0 = static_cast<S1&&>(*x0); // error: object of type 'S1' cannot be a...
      ^
test.cpp:9:5: note: copy assignment operator of 'S1' is implicitly deleted
      because variant field '' has a non-trivial copy assignment operator
    union { // copy assignment operator of 'S1' is implicitly deleted bec...
    ^
2 errors generated.

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

Reply via email to