In article <i_********************@comcast.com>
Ark <ak*****@macroexpressions.com> writes:
Consider the following snippet:
struct x_t x;
struct x_t {
int y;
};
Different compilers disagree (in "strict ANSI" mode) whether it is
legal. What is the truth (in C90 and C99 and anywhere in between)?
The actual text of the wording in the Standards suggests that it
is OK, but the "design" of C -- which aims for all the necessary
information to be available in a one-pass compiler, and it would
not be at that point -- suggests that it is not OK. (Hence it is
not surprising that different C compilers disagree as to whether
this code is strictly conforming.)
C99 seems to list UB case when the complete definition is not in the
same scope as declaration, but in this case it is...
This kind of question really belongs in comp.std.c, since it amounts
to argument over whether a "shall" on page 123 is more important
than some other words on page 97, etc. Here in comp.lang.c the
answer boils down to "don't do that" (because people, and compilers,
cannot agree as to whether it is OK :-) ).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.