From 6074741618169098078
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,954370b2ad698b43
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1993-10-12 16:19:58 PST
Newsgroups: comp.std.c++
Path: gmd.de!xlink.net!howland.reston.ans.net!pipex!uunet!titan!lpi!pkt
From: pkt@lpi.liant.com (Scott Turner)
Subject: Re: refcast ambiguity "((<typename> &) <expression>)"
Message-ID: <1993Oct12.162854.1915@lpi.liant.com>
Sender: pkt@lpi (Scott Turner)
Organization: Liant Software Corporation
References:  <1993Oct6.211357.7098@objy.com>
Date: Tue, 12 Oct 1993 16:28:54 GMT
Lines: 27

In article <1993Oct6.211357.7098@objy.com>, jacob@objy.com (Jacob Butcher) writes:

> most compilers (for example, Sun's) compile these two statements identically:
> 
> 		to &t = f;
> 		to &t = ((to &) (f));
> 
> However, IBM's xlC compiler for AIX on an IBM RT compiles them differently.

> However, their implementation
> violates what I (perhaps naively) assume to be an invariant of the language,
> which is that if it is legal to assign an expression of type F to a variable
> of type T, then it is legal to *cast* an expression of type F to type T, and
> the operations are identical.

That would be nice as an invariant, but C++ explicit casts break it.
For example,

	void foo(float x) {
		const int &r1 = x;         // Refer to a temporary int object.
		const int &r2 = (const int &)x;  // Reinterpret the bits of x.
	}
--
Prescott K. Turner, Jr.
Liant Software Corp. (developers of LPI languages)
959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com


