home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!spool.mu.edu!darwin.sura.net!gatech!concert!sas!mozart.unx.sas.com!sasghm
- From: sasghm@theseus.unx.sas.com (Gary Merrill)
- Newsgroups: comp.lang.c
- Subject: Re: LHS Casting
- Message-ID: <BxtEqM.2qz@unx.sas.com>
- Date: 16 Nov 92 15:23:10 GMT
- References: <1992Nov13.050054.28251@druid.uucp>
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Organization: SAS Institute Inc.
- Lines: 25
- Originator: sasghm@theseus.unx.sas.com
- Nntp-Posting-Host: theseus.unx.sas.com
-
-
- In article <1992Nov13.050054.28251@druid.uucp>, darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- |> I came across some of the ugliest code I have seen in a long time recently.
- |> At one point there is a pointer to char that is declared as a pointer to
- |> int. To get an address within this block of bytes the programmer does:
- |>
- |> (int *) charptr = intptr + (OFFSET/2);
- |>
- |> Well of course this is bad. The FAQ (question 2.13) shows another case
-
- It's not only bad, it is a violation of ANSI. See Section 3.3.4,
- note 41 ("A cast does not yield an lvalue. ...") Some older C
- compilers used to accept this nonsense. I cannot lay my hands on
- a precise reference at the moment, but there was an issue of _Dr.
- Dobbs_ some time in '85 or '86 in which a paper (to the ANSI C
- committtee) written by Francis Lynch and me was reprinted almost in
- its entirety as part of a column on the standardization of C. In
- that paper a number of compelling arguments are offered against
- allowing a cast to be an lvalue. If you can find the appropriate
- issue of the magazine, you might be interested in these arguments.
-
- --
- Gary H. Merrill [Principal Systems Developer, C Compiler Development]
- SAS Institute Inc. / SAS Campus Dr. / Cary, NC 27513 / (919) 677-8000
- sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
-