From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2546 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: NULL Date: Wed, 9 Jan 2013 22:53:27 +0100 Message-ID: <20130109215327.GM4468@port70.net> 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> 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 1357768419 9638 80.91.229.3 (9 Jan 2013 21:53:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jan 2013 21:53:39 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2547-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 09 22:53:56 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 1Tt3at-0003p5-Qq for gllmg-musl@plane.gmane.org; Wed, 09 Jan 2013 22:53:56 +0100 Original-Received: (qmail 25767 invoked by uid 550); 9 Jan 2013 21:53:39 -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 25759 invoked from network); 9 Jan 2013 21:53:39 -0000 Content-Disposition: inline In-Reply-To: <20130109211128.GZ17059@headless> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2546 Archived-At: * 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