[lkml]   [2004]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH][2.6.6-rc3] gcc-3.4.0 fixes
H. Peter Anvin writes:
> Followup to: <>
> By author: Mikael Pettersson <>
> In newsgroup:
> >
> > 'ptr' _is_ a char pointer, and the code (visible in the part of
> > the patch you didn't include) already performed pointer arithmetic
> > on it relying on it being a char pointer. The old code had no
> > sane reason at all for updating 'ptr' via a cast-as-lvalue.
> >
> > cast-as-lvalue is not proper C, has dodgey semantics, and can
> > always be replaced by proper C.
> >
> I don't see how it has dodgey semantics for cast of pointers or
> [u]intptr_t to pointers.

You're assuming pointers have uniform representation.
C makes no such guarantees, and machines _have_ had
different types of representations in the past.
Some not-so-obsolete 64-bit machines in effect use fat
representations for pointers to functions (descriptors),
but they usually cheat and use pointers to the descriptors
instead. However, a C implementation could legally
represent a function pointer as a 128-bit value, while
data pointers remain 64 bits.

A cast fundamentally involves an assignment conversion,
a copy to a temporary, and it yields an rvalue.
Even if we allow its use as an lvalue, the semantics
would still be to assign the copy not the original.
So cast-as-lvalue as gcc implemented it changed two
major aspects of the semantics. Call me conservative
if you like, but that's simply not C any more.

Other gcc extensions, such as __inline__, __attribute__,
and __asm__, do provide useful and sensible features.
The issue with cast-as-lvalue is that it is neither
necessary nor does it promote maintainable and portable code.

Remember "the world's not a VAX" and "the world's not
a 68K with 24-bit addresses" lessons of the 80s,

> IMNSHO the fact that it breaks C++ isn't a good reason to outlaw a
> long-documented extension for C.

I couldn't care less about C++. There are ample reasons
why it's a bad idea in C itself.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 14:03    [W:0.121 / U:5.668 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site