Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mcnc!rti!sheol!throopw From: throopw@sheol.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: Casting the lvalue Summary: casts are conversions Message-ID: <0496@sheol.UUCP> Date: 10 Mar 90 23:49:33 GMT References: <1990Mar6.221457.6801@utzoo.uucp> Lines: 26 > From: henry@utzoo.uucp (Henry Spencer) >> From: psm@manta.nosc.mil.UUCP (Scot Mcintosh) >>The following seems to be illegal... >>(int)array[1] = 5; >>[...]Question: why is [..this..] illegal... > Why should it be legal? What does it *mean*? What Henry left out was that a cast is a conversion of datatype. It is a commonly made mistake to suppose that casts change the type of an object or value without any conversion action sometimes. This is never the case. This has never been the case. Once upon a time, a family of sloppy compilers left the result of a cast an lvalue in some circumstances. Some users of this family of compilers have taken this unfortunate circumstance as Natural Law, ignoring or never obtaining lint's warnings to the contrary. Similar to the naive person who takes the local mores of that person's tribe as Natural Law. Thus, the expression ((int)array[1] = 5) is as meaningless in C as the expression ((a+3) = 5). Thus, Henry's amazement. After all, as he said... What does it *mean*? -- Wayne Throop !mcnc!rti!sheol!throopw or sheol!throopw@rti.rti.org