From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10415 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] fix strdupa evaulating expression twice Date: Tue, 30 Aug 2016 17:03:13 -0400 Message-ID: <20160830210313.GL15995@brightrain.aerifal.cx> References: <20160828150816.GF15995@brightrain.aerifal.cx> <20160828170438.dhcbk2my2gkcp7ot@gordon> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1472591027 30647 195.159.176.226 (30 Aug 2016 21:03:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2016 21:03:47 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10428-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 30 23:03:42 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1beqC5-0007Kt-8o for gllmg-musl@m.gmane.org; Tue, 30 Aug 2016 23:03:41 +0200 Original-Received: (qmail 7502 invoked by uid 550); 30 Aug 2016 21:03:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 7481 invoked from network); 30 Aug 2016 21:03:40 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10415 Archived-At: On Mon, Aug 29, 2016 at 05:40:52AM +0000, Noam Meltzer wrote: > > That said, it looks like glibc only defines strdupa #if __GNUC__, so > > this function is simply unavailable when using a compiler that doesn't > > implement this extension. > > > > I'm not sure what the musl policy is here, but maybe we could do > > something similar? > > The __GNUC__ macros is being used in other parts of musl, so is there a > reason not to move strdupa into a #if __GNUC__ macro? For the most part it's used internally for optimization purposes, not for making the external API vary by compiler capability. However being that alloca need not even work or be defined on non-GNUC compilers, and that this is a nasty error-prone function that shouldn't be used to begin with, I really have no objection to having it only work on GNUC. On the other hand I don't think we even need to put it in #ifdef __GNUC__; if the non-GCC compiler does not accept the syntax, it will just produce an error anyway. Perhaps we should add strndupa too? It's been requested but IIRC it could not be implemented without GNUC extensions. Rich