Article View: comp.std.c
Article #3451Re: (no subject) [cast expression as an lva
From: James Kanze US/ESC 60/3/141 #407...
Date: Wed, 11 Oct 1995 09:59
Date: Wed, 11 Oct 1995 09:59
33 lines
2135 bytes
2135 bytes
In article <45fgea$d8j@yage.tembel.org> shields@tembel.org (Michael
Shields) writes:
|> 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?
Because it fails miserably on machines where different types of
pointers have different representations. I believe it was Henry
Spencer who said something about lying to the compiler...
The problem I think Steve Clamage was addressing is that there are an
awful lot of programmers out there who think that the whole world is
composed of Vaxes and Suns. Their programs once worked on one of
these machines, and they expect everyone else to perpertuate their
errors. Since they often have friends in purchasing, their
expectations may very well be met.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
Technical Details
Message-ID:
<KANZE.95Oct11105909@slsvgqt.lts.sel.alcatel.de>Path:
arc1-ca.pugleaf.net!cett.alcatel-alsthom.fr!slsv6bt!newsReferences:
<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!cett.alcatel-alsthom.fr!slsv6bt!news From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) Subject: Re: (no subject) [cast expression as an lva In-Reply-To: shields@tembel.org's message of 11 Oct 1995 04:16:10 -0000 Message-ID: <KANZE.95Oct11105909@slsvgqt.lts.sel.alcatel.de> Sender: news@lts.sel.alcatel.de Organization: SEL References: <45e68p$t78@inferno.mpx.com.au> <45ef3f$n8u@engnews2.Eng.Sun.COM> <45fgea$d8j@yage.tembel.org> Distribution: inet Date: 11 Oct 1995 09:59:08 GMT