On 29-Mar-2000, Manuel M. T. Chakravarty <[EMAIL PROTECTED]> wrote:
> The code 
> 
>   void *p;
>   struct foo *x;
>   struct bar *y;
> 
>   p = x;  /* (1) */
>   y = x;  /* (2) */
> 
> compiles at (1) without problems, but gives a warning at
> (2).

Actually whether it is an error or a warning is implementation-dependent.
Some C compilers, for example lcc, will report an error for this.  Likewise
`gcc -pedantic-errors' will report an error.

The code is not strictly conforming C, and the C standard requires the
compiler to issue a diagnostic, but a diagnostic can be either an error or a
warning.  (The only thing the C 99 standard requires an error for is the
#error directive.)

> I think that's actually a good idea.  In fact, as this does
> not raise a compile time error, but only a warning, it
> doesn't prevent you at all from doing nasty things at the C
> side (if you entertain such thoughts),

As noted above, with some C compilers it is an error, but in that case you can
easily avoid the error by inserting a cast, so I think your point still holds.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to