<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Missing item referenced in compiler error."
href="http://llvm.org/bugs/show_bug.cgi?id=17413">17413</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missing item referenced in compiler error.
</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>Windows NT
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gmisocpp@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Compile the following program with g++ and clang++ and compare the resulting
output from each compiler. Compiler instructions and output follow this
program.
Note in the output that g++ seems to have a superior error message.
#include <cstdio>
using namespace std;
class my_object {
public:
int id_;
my_object() { }
my_object(int id) : id_(id)
{
printf( "constructed my_object %d\n", id_ );
}
~my_object()
{
printf( "destructed my_object\n" );
}
int get_id() { return id_; }
};
class X {
public:
private:
union {
char storage [sizeof(my_object)];
my_object object;
} y;
};
int main()
{
X x;
}
g++ command line and output:
// libcxx references can be omitted in your tests.
c:\test>g++ -fno-exceptions -static -std=c++11 -Wall moslow2.cpp
-I/libcxx/include -L/libcxx_build/lib -lc++ -omo2.exe
moslow2.cpp: In function 'int main()':
moslow2.cpp:30:7: error: use of deleted function 'X::X()'
X x;
^
moslow2.cpp:18:7: note: 'X::X()' is implicitly deleted because the default
definition would be ill-formed:
class X {
^
moslow2.cpp:18:7: error: use of deleted function 'X::<anonymous
union>::<constructor>()'
moslow2.cpp:22:11: note: 'X::<anonymous union>::<constructor>()' is implicitly
deleted because the default definition woul
d be ill-formed:
union {
^
moslow2.cpp:24:19: error: union member 'X::<anonymous union>::object' with
non-trivial 'my_object::my_object()'
my_object object;
^
moslow2.cpp:18:7: error: use of deleted function 'X::<anonymous
union>::~<constructor>()'
class X {
^
moslow2.cpp:22:11: note: 'X::<anonymous union>::~<constructor>()' is implicitly
deleted because the default definition wou
ld be ill-formed:
union {
^
moslow2.cpp:24:19: error: union member 'X::<anonymous union>::object' with
non-trivial 'my_object::~my_object()'
my_object object;
^
moslow2.cpp:30:7: error: use of deleted function 'X::~X()'
X x;
^
moslow2.cpp:18:7: note: 'X::~X()' is implicitly deleted because the default
definition would be ill-formed:
class X {
^
moslow2.cpp:18:7: error: use of deleted function 'X::<anonymous
union>::~<constructor>()'
c:\test>
Clang compile land and output:
c:\test>clang++ -fno-exceptions -static -std=c++11 -Wall moslow2.cpp
-I/libcxx/include -L/libcxx_build/lib -lc++ -omo2.exe
moslow2.cpp:30:7: error: call to implicitly-deleted default constructor of 'X'
X x;
^
moslow2.cpp:25:7: note: default constructor of 'X' is implicitly deleted
because field 'y' has a deleted default
constructor
} y;
^
moslow2.cpp:24:19: note: default constructor of '' is implicitly deleted
because variant field 'object' has a non-trivial
default constructor
my_object object;
^
1 error generated.
*** I find the g++ error has more clarity then the clang++ error. Note that
clang++ seems to use '' to specify anonymous but it looks like a mistake.
Suggestion, remove use if '' and get nearer to the g++ error.</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>