[LLVMbugs] [Bug 17413] New: Missing item referenced in compiler error.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Sep 30 03:44:46 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17413
Bug ID: 17413
Summary: Missing item referenced in compiler error.
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: gmisocpp at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130930/b6d4cd62/attachment.html>
More information about the llvm-bugs
mailing list