From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2547 Path: news.gmane.org!not-for-mail From: Rob Newsgroups: gmane.linux.lib.musl.general Subject: Re: NULL Date: Wed, 9 Jan 2013 22:17:28 +0000 Message-ID: <20130109221728.GB17059@headless> References: <50ED4E45.6050801@barfooze.de> <50ED81BF.8030005@gentoo.org> <20130109144712.GY20323@brightrain.aerifal.cx> <50ED8A34.5070904@barfooze.de> <20130109153630.GZ20323@brightrain.aerifal.cx> <20130109211128.GZ17059@headless> <20130109215327.GM4468@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1357769863 22897 80.91.229.3 (9 Jan 2013 22:17:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jan 2013 22:17:43 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2548-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 09 23:18:01 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Tt3yC-00016b-FM for gllmg-musl@plane.gmane.org; Wed, 09 Jan 2013 23:18:00 +0100 Original-Received: (qmail 17451 invoked by uid 550); 9 Jan 2013 22:17:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 17440 invoked from network); 9 Jan 2013 22:17:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=yM0k07EQ6jyBVVHvG0+Pa1/b+g8Pit/o4aoPeq7oMhM=; b=fAgAUGrqnJkA+sOLwAdjK9jhlqNVzRvA/FqPwi+3K0VxioCstMDvNNGEjwixt2ZwRH jYgSvgBrbXaG+nwn7Oy4Umnjdxar80JaLV3hy4oZIYXvj4NR6mnKLpnuVXMUdCxdXb8P DajY6WmivGD93/kY0lo4jGOMPu8+yMxoX9xnm0DtPyIA4qGUrgnzb7fe0ZX6qkoRrU+B KowM6d8biJ0Rwb2nZ9/JwRZoz6aXXiZAqwH8rSamERkdBV3D74dgCZ7k9LZMFeCnXBZ0 fDsVF4r13P1OmGpqdxB11uk3WTJSF2exHufBgKF7VwGYnk6PNcexGSdpzlYXg6HkY4I9 7kqQ== X-Received: by 10.180.72.232 with SMTP id g8mr5866764wiv.0.1357769852284; Wed, 09 Jan 2013 14:17:32 -0800 (PST) Content-Disposition: inline In-Reply-To: <20130109215327.GM4468@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2547 Archived-At: On Wed, Jan 09, 2013 at 10:53:27PM +0100, Szabolcs Nagy wrote: > * Rob [2013-01-09 21:11:28 +0000]: > > On Wed, Jan 09, 2013 at 10:36:30AM -0500, Rich Felker wrote: > > > char s[1][1+(int)NULL]; > > > int i = 0; > > > return sizeof s[i++], i; > > > > Magic... is `s' a VLA here? My mind is boggled because > > __builtin_constant_p(1+(int)NULL) returns 1, and I can't think of any > > reason why the sizeof is evaluated. > > > > Also, seeing that clang and tcc return 0 in all cases, is this a bug in > > both of them? > > sizeof evaluates its argument if and only if it is a vla > (c11 6.5.3.4p2) > > in c99 (and c11) vla is created if the size in the array > declarator is not an "integer constant expression" > (c11 6.7.6.2p4) > > eg '1 + (int)(void*)0' is not an integer constant expression > because of the pointer cast, but '1 + (int)0' is > (c11 6.6p6) > > hence sizeof s[i++] evaluates the argument if NULL has a pointer > cast in it Ah, thanks for the explanation.