This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54548] New: unclear error message for ambiguous type lookup.
- From: "pluto at agmk dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 11 Sep 2012 11:00:20 +0000
- Subject: [Bug c++/54548] New: unclear error message for ambiguous type lookup.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54548
Bug #: 54548
Summary: unclear error message for ambiguous type lookup.
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pluto@agmk.net
#include <new>
struct X;
namespace { struct X; }
int main()
{
new X();
}
a gcc error message is unreadable for end-user in case when
the first 'struct X' decl is hidden deeply in the #include forest.
$ LANG=C g++ -Wall t.cpp -c
t.cpp: In function 'int main()':
t.cpp:6:6: error: expected type-specifier before 'X'
t.cpp:6:6: error: expected ';' before 'X'
clang is more user-friendly and shows problem directly.
$ LANG=C clang++ -Wall t.cpp -c
t.cpp:6:6: error: reference to 'X' is ambiguous
new X();
^
t.cpp:2:8: note: candidate found by name lookup is 'X'
struct X;
^
t.cpp:3:20: note: candidate found by name lookup is '<anonymous namespace>::X'
namespace { struct X; }
^
t.cpp:6:6: error: allocation of incomplete type 'X'
new X();
^
t.cpp:2:8: note: forward declaration of 'X'
struct X;
^
2 errors generated.