mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] fix strdupa evaulating expression twice
Date: Tue, 30 Aug 2016 17:03:13 -0400	[thread overview]
Message-ID: <20160830210313.GL15995@brightrain.aerifal.cx> (raw)
In-Reply-To: <CADtAWjANZ-y0rWSz-wcuV6dNyuph41J5jcTC97jmG6eZCzW=1w@mail.gmail.com>

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


      reply	other threads:[~2016-08-30 21:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 10:59 Noam Meltzer
2016-08-28 15:08 ` Rich Felker
2016-08-28 16:53   ` Noam Meltzer
2016-08-28 17:04     ` Bobby Bingham
2016-08-29  5:40       ` Noam Meltzer
2016-08-30 21:03         ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160830210313.GL15995@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).