This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13927] New: confusing error message on ibad redeclaration of anon union
- From: "mec dot gnu at mindspring dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2004 06:23:49 -0000
- Subject: [Bug c++/13927] New: confusing error message on ibad redeclaration of anon union
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider this ill-formed program:
int main ()
{
union { int alpha; int beta; };
double alpha;
return 0;
}
This is bad because "alpha" is declared twice.
gcc HEAD says:
/berman/fsf/_today_/berman/install/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/bin/g++
-S au-3.cc
au-3.cc: In function `int main()':
au-3.cc:4: error: `double alpha' redeclared as different kind of symbol
au-3.cc:3: error: previous declaration of `#`alias_decl' not supported by
dump_decl#<declaration error>'
au-3.cc:4: error: declaration of `double alpha'
au-3.cc:3: error: conflicts with previous declaration `#`alias_decl' not
supported by dump_decl#<declaration error>'
This doesn't bother me because the line numbers do point to the right place so
that people can get work done. But it might be nicer if gcc could print a
better error message.
That is, I wouldn't mind a WONTFIX on this one, if fixing it would make the
compiler less elegant. But I suspect that there is code which doesn't know
about these strange types created by anon union variables so it might be good to
fix this.
For comparison, gcc 3.3.2 prints:
au-3.cc: In function `int main()':
au-3.cc:4: error: conflicting types for `double alpha'
au-3.cc:3: error: previous declaration as `int alpha'
--
Summary: confusing error message on ibad redeclaration of anon
union
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mec dot gnu at mindspring dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13927