%% Tom Tromey <[EMAIL PROTECTED]> writes:

  tom> Paul says the current C standard doesn't allow [the struct hack],

No, actually I said the _current_ C standard _does_ allow it--at least
using the [0] notation; the current standard is C99 :).  It's the
_previous_ standard, C89, that doesn't :)

Just to be picky.

  tom> but I thought there was a special exception precisely to allow
  tom> it.

Nope.  The C FAQ, question 2.6:

> This technique is popular, although Dennis Ritchie has called it
> ``unwarranted chumminess with the C implementation.'' An official
> interpretation has deemed that it is not strictly conforming with the
> C Standard. (A thorough treatment of the arguments surrounding the
> legality of the technique is beyond the scope of this list.) It does
> seem to be portable to all known implementations. (Compilers which
> check array bounds carefully might issue warnings.)
>
> Another possibility is to declare the variable-size element very
> large, rather than very small; in the case of the above example:
>
>        ...
>        char namestr[MAXSIZE];
>        ...
>
> where MAXSIZE is larger than any name which will be stored. However,
> it looks like this technique is disallowed by a strict interpretation
> of the Standard as well.
>
> References: Rationale Sec. 3.5.4.2 

  tom> Anyway, it is a very common practice.

Indeed.  I've used it many times myself and never once thought twice
about it.  It's hard to imagine the contortions a C compiler would need
to go through to _dis_-allow it.

I'm just in a pedantic kinda mood today :).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.

Reply via email to