Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Lvalues and casts Message-ID: <17707@mimsy.UUCP> Date: 23 May 89 22:48:00 GMT References: <847@tub.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 28 In article <847@tub.UUCP> net@tub.UUCP (Oliver Laumann) writes: -I just found out (by accident; I didn't want to actually use it) -that the GNU cc with the -ansi option, the cc under SunOS 4.0 and -the Greenhills C-compiler all happily compile the following program -(without any warnings): - - f () { - int *ip; - char *cp; - - (int *)cp = ip; - } - -The PCC, however, says "illegal lvalue in assignment". Is this legal -C, i.e. is the result of a cast really an lvalue? The result of a cast is not an lvalue (is an rvalue). GCC accepts it as an extension; the Greenhills compiler probably accepts it because some versions of PCC did; correct PCCs reject it. If you compile with gcc -ansi -pedantic GCC does reject the assignment. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris