This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pointer <-> integer round-up


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]