[Bug c++/15049] [3.5 Regression] [DR 278/132/216/338/389/319] global variables with anonymous types are legal
austern at apple dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 22 21:15:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list