From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id CD22A2EFA0 for ; Tue, 9 Jan 2001 11:35:08 -0500 (EST) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id f09GZ8v28312 for axp-list@listman.redhat.com; Tue, 9 Jan 2001 11:35:08 -0500 Received: from ellpspace.math.ualberta.ca (IDENT:michal@ellpspace.math.ualberta.ca [129.128.207.67]) by mail.redhat.com (8.11.0/8.8.7) with ESMTP id f09GZ8D28306 for ; Tue, 9 Jan 2001 11:35:08 -0500 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.9.3/8.9.3) id JAA02781 for axp-list@redhat.com; Tue, 9 Jan 2001 09:35:04 -0700 Date: Tue, 9 Jan 2001 09:35:04 -0700 From: Michal Jaegermann To: axp-list@redhat.com Subject: Re: ccc error Message-ID: <20010109093504.A2754@ellpspace.math.ualberta.ca> References: <20010109104941.A23344@twister.gmd.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4us In-Reply-To: <20010109104941.A23344@twister.gmd.de>; from Georg Wittig on Tue, Jan 09, 2001 at 10:49:41AM +0100 X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors On Tue, Jan 09, 2001 at 10:49:41AM +0100, Georg Wittig wrote: > jeff.sturm@appnet.com wrote: > > > > Does anyone know if the following is valid C: > > > > extern int a; > > extern int b; > > > > void f(int x) { > > (x ? a : b) = 1; > > } > > > (OT, because this question has nothing to do with axp) > > Don't know if it's valid C. No, it is not. gcc has a number of extentsions. In particular it will accept expressions as "lvalues" ("lvalue", in short, is something which can show up on the left hand side of an assignment). 'info gcc' and try to find 'Lvalues' under 'C Extensions'. > But remember you can always write this as > * (x? &a : &b) = 1; This should have the same problem as the above but if you will expand it to int *p = (x? &a : &b) ; *p = 1; which is really the same thing (and probably will compile to the same code as the original '(x ? a : b) = 1;'), and is valid C. What is wrong with void f(int x) { if (0 != x) a = 1; else b = 1; } You can even squish that into a one line if you really want to. :-) BTW, 'if(x)' will earn you moanings from gcc; you would have to write 'if((x))' if you are (mis)saving on an explicit test. Michal