pointer <-> integer round-up
Fergus Henderson
fjh@cs.mu.OZ.AU
Tue Mar 19 18:15:00 GMT 2002
On 19-Mar-2002, Tom Lord <lord@emf.net> wrote:
>
> Conversions from integer to pointer types are legal in some
> circumstances, but not as an implicit (castless) conversion, as in an
> assignment to an integer variable. I thought they were legal in that
> case (not wise to use, certainly worthy of a warning, but legal).
> That's the traditional behavior of C. It's what GCC compiles. I'd
> bet we can find old code that relies on that implicit conversion. But
> according to the strictest reading of the standard, GCC _could_ treat
> such an assignment as an error and refuse to compile the program. My
> mistake.
This is not just a theoretical issue; lcc, for example, reports an
error for such assignments. There is no way to change this error
to a mere warning. The only way to compile programs containing such
assignments with lcc is to insert an appropriate cast.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
More information about the Gcc
mailing list