Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Why is this legal?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John F. Woods  
View profile  
 More options Feb 25 1992, 6:25 pm
Newsgroups: comp.std.c
From: j...@ksr.com (John F. Woods)
Date: 25 Feb 92 14:51:52 EST
Local: Tues, Feb 25 1992 2:51 pm
Subject: Re: Why is this legal?
bhoug...@hopi.intel.com (Blair P. Houghton) writes:

>In article <10...@ksr.com> j...@ksr.com (John F. Woods) writes:
>>bhoug...@hopi.intel.com (Blair P. Houghton) writes:
>>>struct foo *foo;
>>>main(){ printf("*foo size: %d\n", sizeof(struct foo) );
>>At this point, the compiler is at liberty to generate a program which formats
>>your hard disk drive.  In fact, it probably should.  3.3.3.4, 1.6, six two and
>>even, over and out.
>But tell us WHY, Dr. Define....

"3.1.2.5 Types
 A structure or union type of unknown content (as described in 3.5.2.3)
 is an incomplete type."
"3.3.3.4 The sizeof Operator
 Constraints
    The sizeof operator shall not be applied to an expression that has
 function type or an incomplete type, to the parenthesized name of such
 a type, ..."
"1.6 Definitions of Terms
 In this standard, ... "shall not" is to be interpreted as a prohibition.
 * Undefined behavior -- behavior, upon use of a nonportable or erroneous
 program construct, ... for which the standard imposes no requirements.
 Permissible undefined behavior ranges from ignoring the situation completely
 with unpredictable results, to having demons fly out of your nose."

In short, you can't use sizeof() on a structure whose elements haven't been
defined, and if you do, demons may fly out of your nose.

OK, OK; so the Standard doesn't *ACTUALLY* mention demons or noses.  Not as
such, anyway.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.