This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15049] [3.5 Regression] [DR 278/132/216/338/389/319] global variables with anonymous types are legal
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jul 2004 21:15:55 -0000
- Subject: [Bug c++/15049] [3.5 Regression] [DR 278/132/216/338/389/319] global variables with anonymous types are legal
- References: <20040421173812.15049.austern@apple.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From austern at apple dot com 2004-07-22 21:15 -------
There's no mystery about the cause of this behavior. It's in cp/decl.c:
if (TYPE_ANONYMOUS_P (t))
{
if (DECL_EXTERN_C_P (decl))
/* Allow this; it's pretty common in C. */;
else
{
pedwarn ("non-local variable `%#D' uses anonymous type",
decl);
if (DECL_ORIGINAL_TYPE (TYPE_NAME (t)))
cp_pedwarn_at ("\
`%#D' does not refer to the unqualified type, so it is not used for linkage",
TYPE_NAME (t));
}
}
else
pedwarn ("non-local variable `%#D' uses local type `%T'",
decl, t);
cvs annotate shows that this is a change the Geoff made on 04-Mar-04.
The only question is what to do about this change. Having read the relevant parts of C++03 standard
and looked at all relevant CWG issues, I believe that
struct { int x; } my_global;
is dubious but legal C++. ("Dubious" becuase I think it's likely to become illegal in some future
standard.)
So I believe the right solution is to change that first pedwarn to a warning.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15049