Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 30 Aug 2016 17:03:13 -0400
From: Rich Felker <>
Subject: Re: [PATCH] fix strdupa evaulating expression twice

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.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.