From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18327 invoked by alias); 20 Nov 2004 01:40:48 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 18313 invoked from network); 20 Nov 2004 01:40:44 -0000 Received: from unknown (HELO vaxjo.synopsys.com) (198.182.60.75) by sourceware.org with SMTP; 20 Nov 2004 01:40:44 -0000 Received: from crone.synopsys.com (crone.synopsys.com [146.225.7.23]) by vaxjo.synopsys.com (Postfix) with ESMTP id AECDEDB46; Fri, 19 Nov 2004 17:40:43 -0800 (PST) Received: from piper.synopsys.com (localhost [127.0.0.1]) by crone.synopsys.com (8.9.1/8.9.1) with ESMTP id RAA14714; Fri, 19 Nov 2004 17:40:43 -0800 (PST) Received: (from jbuck@localhost) by piper.synopsys.com (8.11.6/8.11.6) id iAK1egn02130; Fri, 19 Nov 2004 17:40:42 -0800 X-Authentication-Warning: piper.synopsys.com: jbuck set sender to Joe.Buck@synopsys.com using -f Date: Sat, 20 Nov 2004 05:04:00 -0000 From: Joe Buck To: Ziemowit Laski Cc: gcc mailing list , Michael Matz , Matt Austern , Andrew Pinski , Mike Stump Subject: Re: generalized lvalues Message-ID: <20041119174042.A1311@synopsys.com> References: <4D2CF60C-3919-11D9-8BD2-000A95BCF344@apple.com> <20041117212847.A26376@synopsys.com> <6F5FC748-7BBD-44B9-8DDC-246949F16102@apple.com> <20041118102741.A8347@synopsys.com> <77E8D36A-C0C2-4B03-964C-BEE0FE7BBBC3@apple.com> <98C86CD4-39E2-11D9-B2D5-000A95BCF344@apple.com> <20041119170011.A30410@synopsys.com> <9E6AD708-3A93-11D9-9070-000D9330C50E@apple.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <9E6AD708-3A93-11D9-9070-000D9330C50E@apple.com>; from zlaski@apple.com on Fri, Nov 19, 2004 at 05:29:27PM -0800 X-SW-Source: 2004-11/txt/msg00713.txt.bz2 On Fri, Nov 19, 2004 at 05:29:27PM -0800, Ziemowit Laski wrote: > What I was hoping for is that we can turn > > (cast)expr = ... > *(cast)expr)++ > into > > *((cast *)&expr) = ... > *((cast *)&expr)++ > > when -fassign-to-cast is specified. So, it appears that you want to turn (cast)expr into *((cast *)&expr). You still have the issue with C++ overloading; since it is an lvalue, if you have void func(cast&); void func(const cast&); then func((cast)expr) will call the wrong function, because with your rule, func(cast&) gets called, while with the ISO C++ rule, func(const cast&) gets called. Now, you could get around this if you can specify a rule that explains which casts get transformed and which don't. This might be doable. Also, if cast and typeof(expr) are not compatible types by the aliasing rules of C, and the casted expression is written to, then the resulting code may be mis-optimized unless the user also specifies -fno-strict-alias. I'd rather see Objective-C/C++ written in such a way that they don't rely on writing to casts, though.