<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang emits misleading diagnostic messages about copy assignment operators when a class has a nested anonymous union member"
href="https://bugs.llvm.org/show_bug.cgi?id=40555">40555</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang emits misleading diagnostic messages about copy assignment operators when a class has a nested anonymous union member
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ahatanak@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>