[Bug c++/51427] New: Less-than-useful error message when union/struct tags conflict
ajax at redhat dot com
gcc-bugzilla@gcc.gnu.org
Mon Dec 5 20:52:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51427
Bug #: 51427
Summary: Less-than-useful error message when union/struct tags
conflict
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ajax@redhat.com
CC: dodji@gcc.gnu.org
[ajax@f17 tmp]$ cat test.c
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _GMutex GMutex;
typedef union _GMutex GMutex;
#ifdef __cplusplus
};
#endif
[ajax@f17 tmp]$ g++ -Wall -c -o test.o test.c
test.c:5:19: error: ‘union’ tag used in naming ‘struct _GMutex’ [-fpermissive]
This message is unhelpful. At the very least it should say where the
conflicting typedef came from, since it could easily be in a different file.
The text itself is a bit unclear as well, something more like "GMutex already
defined as 'struct _GMutex' at ..." might be better.
Note that the C frontend gets this right already:
[ajax@f17 tmp]$ gcc -Wall -c -o test.o test.c
test.c:5:19: error: ‘_GMutex’ defined as wrong kind of tag
test.c:5:27: error: conflicting types for ‘GMutex’
test.c:4:28: note: previous declaration of ‘GMutex’ was here
More information about the Gcc-bugs
mailing list