kurt@fluke.UUCP (Kurt Guntheroth) (09/18/85)
Index: </usr/src/lib/pcc>/<source file> 4.2BSD
Description:
The Vax 4.2 C compiler incorrectly generates a fatal error message
when castes to a pointer type appear on the lhs of an assignment.
The SUN C compiler and other c compilers I have tried correctly
handle this assignment.
The example below is artificial. I know there is a way to recode it
to avoid this bug, but that is not the point.
Repeat-By:
Compiling the following file % cc -c test.c
------------ test.c ---------------
main()
{
struct foo { int a,b; } ;
char * malloc();
char * cp;
((struct foo *) cp) = (struct foo *) malloc (sizeof (struct foo));
}
--------- end of test.c ------------
"test.c", line 8: illegal lhs of assignment operator
--
Kurt Guntheroth
John Fluke Mfg. Co., Inc.
{uw-beaver,decvax!microsof,ucbvax!lbl-csam,allegra,ssc-vax}!fluke!kurt
henry@utzoo.UUCP (Henry Spencer) (09/19/85)
> The Vax 4.2 C compiler incorrectly generates a fatal error message > when castes to a pointer type appear on the lhs of an assignment. > The SUN C compiler and other c compilers I have tried correctly > handle this assignment. I believe that modern definitions of C make it clear that this is not legal C; the SUN C compiler (and others) are being sloppy. The cast has to go on the right-hand-side, casting the value to the type of the variable rather than vice-versa. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry
chris@umcp-cs.UUCP (Chris Torek) (09/21/85)
Casting an lvalue turns it into an rvalue; rvalues may not be used as the lhs of an assignment operator. Thus the compiler is correct to complain. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland