🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3455

Re: (no subject) [cast expression as an lva

#3455
From: Stephen Baynes
Date: Wed, 11 Oct 1995 07:18
27 lines
1868 bytes
Michael Shields (shields@tembel.org) wrote:
: In article <45ef3f$n8u@engnews2.Eng.Sun.COM>,
: Steve Clamage <clamage@Eng.Sun.COM> wrote:
: > What's interesting is that you can get the same effect with valid code
: > that should generate the same object code as the invalid original.
: > For example, instead of 
: > 	((char*)src)++;
: > you can write
: > 	(*(char**)(&src))++;
: > I don't claim this code is more readable, but you could encapsulate the
: > ugliness in a macro. For example:
: > 	#define increment_as(ptr, T) ((*(T*)(&ptr))++)
: > 	increment_as(src, char*);

: If it is always possible, why not just legalize the first syntax?

The fact that it is possible does not mean it is a good idea or even that
it will give useful results. [For example if pointers have different
representations then the code will compile and do something - but it won't
be very useful.] Also as have already been mentioned you can get alignment 
problems which will make this sort of thing of restricted use.

--
Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton                                 My views are my own.
United Kingdom
Technical Details
Message-ID: <DG9wBE.Ez1@ukpsshp1.serigate.philips.nl>
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
References: <45e68p$t78@inferno.mpx.com.au> <45ef3f$n8u@engnews2.Eng.Sun.COM> <45fgea$d8j@yage.tembel.org>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c,comp.unix.solaris
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Subject: Re: (no subject) [cast expression as an lva
Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
Message-ID: <DG9wBE.Ez1@ukpsshp1.serigate.philips.nl>
Date: Wed, 11 Oct 1995 07:18:50 GMT
Distribution: inet
References: <45e68p$t78@inferno.mpx.com.au> <45ef3f$n8u@engnews2.Eng.Sun.COM> <45fgea$d8j@yage.tembel.org>
Organization: Philips Semiconductors, Southampton, UK
X-Newsreader: TIN [version 1.2 PL2]
Followup-To: comp.std.c,comp.lang.c,comp.unix.solaris