From 8456336931135478228
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,41f149bc3eb8fe8d
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-11-24 04:58:13 PST
Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!psuvax1!uwm.edu!cs.utexas.edu!swrinde!pipex!uunet!zib-berlin.de!cs.tu-berlin.de!mfx
From: mfx@cs.tu-berlin.de (Markus Freericks)
Newsgroups: comp.std.c++
Subject: Re: Casting of lvalues - need language lawyer
Date: 24 Nov 1994 12:52:09 GMT
Organization: TU Berlin Fachbereich Informatik
Lines: 24
Distribution: usa
Message-ID: <3b21td$6ml@news.cs.tu-berlin.de>
References: <CzqnL1.K11@wiretap.spies.com>
NNTP-Posting-Host: lenin.cs.tu-berlin.de
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
In-reply-to: jxski@wiretap.spies.com's message of 23 Nov 1994 21:58:13 MET

In article <CzqnL1.K11@wiretap.spies.com> jxski@wiretap.spies.com (Xski) writes:
> Given the following code snippet:
> 
> void foo()
> {
>   unsigned short bs;
>   (int)bs = -1;
> };
> 
> MSC and WatcomC both flag the assignment as an error.  I *KNOW* its
> crappy coding style, but why is it an error in C++? 
[..]

Look at the ARM, Section 5.4, p. 69. It says "The result of a cast to a
reference type is an lvalue; the results of other casts are not".  and
gives the example 

	int i = 1;
	(float) i = 1.2;	// error
	(float&)i = 1.2;	// nonportable

Hope that helps,

	Markus


