Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > help?: incomplete definition with complete definition in scope

Reply
Thread Tools

help?: incomplete definition with complete definition in scope

 
 
Ark
Guest
Posts: n/a
 
      08-07-2004
Hello NG,
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)?
C99 seems to list UB case when the complete definition is not in the
same scope as declaration, but in this case it is...
Thank you,
Ark
 
Reply With Quote
 
 
 
 
Chris Torek
Guest
Posts: n/a
 
      08-07-2004
In article <(E-Mail Removed)>
Ark <(E-Mail Removed)> 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 (4039.22'N, 11150.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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
About incomplete class definition CC Jia C++ 2 10-30-2010 11:35 PM
Re: Lexical scope vs. dynamic scope Xah Lee Java 0 02-26-2009 10:08 AM
Scope - do I need two identical classes, each with different scope? ann Java 13 09-13-2005 03:07 AM
How do namespace scope and class scope differ? Steven T. Hatton C++ 9 07-19-2005 06:07 PM
IMPORT STATIC; Why is "import static" file scope? Why not class scope? Paul Opal Java 12 10-10-2004 11:01 PM



Advertisments