From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28207 invoked by alias); 20 Nov 2004 01:51:42 -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 28168 invoked from network); 20 Nov 2004 01:51:34 -0000 Received: from unknown (HELO mail-out3.apple.com) (17.254.13.22) by sourceware.org with SMTP; 20 Nov 2004 01:51:34 -0000 Received: from mailgate2.apple.com (a17-128-100-204.apple.com [17.128.100.204]) by mail-out3.apple.com (8.12.11/8.12.11) with ESMTP id iAK1vffN012397 for ; Fri, 19 Nov 2004 17:57:42 -0800 (PST) Received: from relay3.apple.com (relay3.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.3.14) with ESMTP id ; Fri, 19 Nov 2004 17:51:33 -0800 Received: from [17.201.24.57] (polskifiat.apple.com [17.201.24.57]) by relay3.apple.com (8.12.11/8.12.11) with ESMTP id iAK1pUSV016825; Fri, 19 Nov 2004 17:51:31 -0800 (PST) In-Reply-To: <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> <20041119174042.A1311@synopsys.com> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <90DC5074-3A96-11D9-9070-000D9330C50E@apple.com> Content-Transfer-Encoding: 7bit Cc: gcc mailing list , Michael Matz , Matt Austern , Andrew Pinski , Mike Stump From: Ziemowit Laski Subject: Re: generalized lvalues Date: Sat, 20 Nov 2004 05:17:00 -0000 To: Joe Buck X-SW-Source: 2004-11/txt/msg00714.txt.bz2 On 19 Nov 2004, at 17.40, Joe Buck wrote: > 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. Only casts that are assigned to (or incremented or decremented) would be transformed, and so only if _those_ casts are subsequently referenced do we run into the problems you describe. The 'func((cast)expr)' example you describe will be untouched. To put it another way, I'm only concerned with cases where the compiler currently complains about assigning to a non-lvalue, and the non-lvalue in question is a cast of an lvalue. --Zem