From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2570 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: NULL Date: Sun, 13 Jan 2013 18:47:32 +0100 Message-ID: <20130113174731.GS4468@port70.net> References: <20130112133114.GH20323@brightrain.aerifal.cx> <1358087360.32505.12@driftwood> 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 1358099264 14848 80.91.229.3 (13 Jan 2013 17:47:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Jan 2013 17:47:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2571-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jan 13 18:48:02 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 1TuRf7-0007ZU-Mq for gllmg-musl@plane.gmane.org; Sun, 13 Jan 2013 18:48:01 +0100 Original-Received: (qmail 30517 invoked by uid 550); 13 Jan 2013 17:47:44 -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 30509 invoked from network); 13 Jan 2013 17:47:44 -0000 Content-Disposition: inline In-Reply-To: <1358087360.32505.12@driftwood> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2570 Archived-At: * Rob Landley [2013-01-13 08:29:20 -0600]: > On 01/12/2013 07:31:14 AM, Rich Felker wrote: > >It does. (int)0 is an integer constant expression. (int)(void *)0 > >happens to be semantically constant, but it's not an integer constant > >expression. > > Really? > > Toybox main.c is doing: > > #define NEWTOY(name, opts, flags) opts || > #define OLDTOY(name, oldname, opts, flags) opts || > static const int NEED_OPTIONS = > #include "generated/newtoys.h" > 0; // Ends the opts || opts || opts... > > Which basically boils down to either: > > NEED_OPTIONS = "STRING" || NULL || "STRING"; > > Or: > > NEED_OPTIONS = NULL || NULL || NULL; > > Then it does: > > if (NEED_OPTIONS) call_option_parsing_stuff(); > > And then dead code elimination zaps the option parsing stuff if it's > only ever called behind and if (0). I tested this to make sure it > worked. Years ago I actually upgraded tinycc to make that behave the > same way gcc behaved so it could build this. (Yes, I could make it a > compile probe setting a config symbol before the main build, but I > didn't _need_ to.) > > So I think you're saying is that the behavior I'm depending on changed? well, (int)(void*)0 is not an "integer constant expression" and it is not a "null pointer constant", it is not an "arithmetic constant expression" nor an "address constant", but an implementation is allowed to accept it as a "constant expression" anyway (as far as i can see it is not required to though) !(void*)0 and (void*)0 || (void*)0 are similar in initializers they may be accepted, but the standard does not require them to be gcc used to be less strict integer constant expressions, but recently it follows the standard more closely > Sigh. Yup. When I build toybox with just "true", gcc 4.2.1 (last gpl > release) drops out parse_optflag() but the ubuntu host toolchain no > longer does. i think gcc should be able to do the optimization i guess gcc assumes that the value of 'static const' objects may change or may not be available at compile-time for some reason may be the following works: #define NEWTOY(name, opts, flags) opts || #define OLDTOY(name, oldname, opts, flags) opts || if ( #include "generated/newtoys.h" 0) call_option_parsing_stuff();