From -2207821338113808717
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,41f149bc3eb8fe8d
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-11-25 18:27:13 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!agate!darkstar.UCSC.EDU!news.hal.COM!decwrl!borland.com!news
From: peterk@borland.com (Peter Kukol)
Subject: Re: Casting of lvalues - need language lawyer
Message-ID: <CzurLr.KK6@borland.com>
Sender: news@borland.com (News Admin)
Organization: Borland
X-Newsreader: WinVN 0.93.6
References: <CzqnL1.K11@wiretap.spies.com> <3b21td$6ml@news.cs.tu-berlin.de>
Mime-Version: 1.0
Distribution: usa
Date: Sat, 26 Nov 1994 02:12:46 GMT
Lines: 20

>void foo()
>{
>  unsigned short bs;
>  (int)bs = -1;
>};

Sadly, this used to be pretty common practice with DOS "C" compilers, and
both VC++ and (16-bit versions of) Borland C++ accept the above when it's
compiled as "C" code (16-bit versions of BC++ also accept it in C++, as
long as strict -A mode is not enabled). The 32-bit versions of BC++ always
reject the above code as an error, though, and to my knowledge Watcom has
always (correctly) rejected it. You've probably seen the reference to the
ARM where this is outlawed; for ANSI "C", check section 3.3.4 for the
same.

This construct is a frequent source of confusion, but hopefully it will
disappear as fewer and fewer implementations tolerate it.

Peter



