From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23619 invoked by alias); 19 Nov 2004 12:38:53 -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 23510 invoked from network); 19 Nov 2004 12:38:41 -0000 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 19 Nov 2004 12:38:41 -0000 Received: (qmail 31834 invoked from network); 19 Nov 2004 12:38:39 -0000 Received: from localhost (HELO ?192.168.189.167?) (nathan@127.0.0.1) by mail.codesourcery.com with SMTP; 19 Nov 2004 12:38:39 -0000 Message-ID: <419DE946.2090705@codesourcery.com> Date: Fri, 19 Nov 2004 13:10:00 -0000 From: Nathan Sidwell Organization: Codesourcery LLC User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 MIME-Version: 1.0 To: Ziemowit Laski CC: Zack Weinberg , Matt Austern , gcc mailing list , Joe Buck Subject: Re: generalized lvalues References: <8AD5AEEF-3914-11D9-8BD2-000A95BCF344@apple.com> <852F83A5-39B9-11D9-8317-00039390FFE2@apple.com> <87zn1eiuy4.fsf@codesourcery.com> <39B69E96-39C9-11D9-8317-00039390FFE2@apple.com> In-Reply-To: <39B69E96-39C9-11D9-8317-00039390FFE2@apple.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-11/txt/msg00677.txt.bz2 Ziemowit Laski wrote: > The "cleanest" syntactic approach we could come up with so far is > > __builtin_objc_gc_strong(ptr) = object; > > which I suppose we can live with, though the lhs doesn't look too > lvaluish this way... :-( It looks more lvaluish than '(cast)ptr = object'. Functions can return references (in C++), so one could actually write such a function. The same is not true of the cast notation. void *&__builtin_objc_gc_strong(void *&p) {return p;} Do you need a solution that works in both C and C++? If you're adding language extensions, you should choose one that is the smallest possible extension (ideally, it would be 'not-an-extension'). The cast-as-lvalue idea fails for C++, as Joe Buck has pointed out, and it fails for C as it makes a whole swathe of ill-formed uses now well-formed, but with non-intuitive semantics. For instance does '(short)int_var = something' write only the 'short' bits of int_var, or the whole thing? What does '(int)short_var = something' mean? What does '&(short)int_var' give you? Is it endian-dependent? Sure, meanings could be defined, but ISTM that there's a whole rat's nest of strange corner conditions ready trip up programmers and compilers. nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk