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: generalized lvalues -- patch outline


>>>>> "Thomas" == Thomas Kunert <kunert@physik.tu-dresden.de> writes:

 Thomas> Paul Koning wrote:
 >>>>>>> "Eric" == Eric Botcazou <ebotcazou@libertysurf.fr> writes:
 >> 
 >> 
 >> >> The average C programmer would not have thought to use this >>
 >> extension unless they just decided one day to try it or they >>
 >> actually read the gcc documentation (which I know almost nobody >>
 >> does).
 >> 
 Eric> I disagree: *((int *)p)++ was accepted by virtually all the
 Eric> good old compilers: GCC 2.x, Microsoft, Borland, Watcom.  This
 Eric> is a natural idiom when you're manipulating images with
 Eric> different color depths ...
 >> ... or doing alignment-optimized copying.  I've seen this notation
 >> in our code, and I'm pretty sure the author didn't get it from the
 >> GCC docs.  It's a natural thing to write -- unless you ARE a
 >> language lawyer and understand the hairy details of precisely what
 >> is an lvalue and what is not.
 >> 

 Thomas> A union is the correct solution.

 Thomas> union { char* c; int* i; short* s; } p;

 Thomas> *p.i++;

But that depends on char* and int* having the same representation,
doesn't it?

	paul


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