From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Define NULL as __null in C++ mode when using GCC or Clang.
Date: Wed, 10 Jul 2019 17:16:24 -0400 [thread overview]
Message-ID: <20190710211624.GX1506@brightrain.aerifal.cx> (raw)
In-Reply-To: <20190710211154.GL21055@port70.net>
On Wed, Jul 10, 2019 at 11:11:55PM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2019-07-10 16:48:12 -0400]:
> > On Wed, Jul 10, 2019 at 01:35:35PM -0400, James Y Knight wrote:
> > > My leaning would kinda be to use
> > > > nullptr in recent C++ versions and retain 0L for old ones if nullptr
> > > > is a valid definition in new C++ versions, but I still wonder if
> > > > having use of NULL "break maximally" isn't a better behavior with
> > > > respect to ending its use...
> > > >
> > >
> > > #define NULL nullptr is standards-valid in c++11 and later, but would be an
> > > unfortunate choice to make. Both in terms of breaking working code (code
> > > which is making unportable assumptions, granted), but also in terms of
> > > breaking ABIs on valid code: changing the type from long to
> > > decltype(nullptr) changes mangling, etc.
> >
> > Could you clarify how it "breaks ABI"? NULL is not a type but a macro
> > expanding to an expression. Does its type somehow leak into mangled
> > symbol names via templates or something? If so, this is a complication
> > to any proposed change of the type.
>
> void f(int);
> void f(long);
> void f(void*);
> ....
> f(NULL); // if NULL is 0 vs 0L then the int vs long version is called.
>
> so the dispatch (and called symbol) depends on the definition of NULL
>
> __null behaves like 0L, nullptr would dispatch to the void* version.
I see. I don't see this as ABI breakage, but rather as a change in the
behavior produced by non-portable code. But I wonder if it's also
possible to see ABI breakage from a change.
> i think modern c++ code should use nullptr in the code.
>
> definition of NULL should be imo kept as 0L (that's what
> you would get on older unix systems or on openbsd anyway)
> apparently some ppl prefer __null.
Do you know if OpenBSD has a reason they do it this way?
Rich
next prev parent reply other threads:[~2019-07-10 21:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 19:19 James Y Knight
2019-07-09 19:38 ` Rich Felker
2019-07-09 23:04 ` James Y Knight
2019-07-10 2:03 ` Szabolcs Nagy
2019-07-10 6:34 ` Florian Weimer
2019-07-10 8:46 ` Szabolcs Nagy
2019-07-10 16:18 ` James Y Knight
2019-07-10 16:44 ` Rich Felker
2019-07-10 17:35 ` James Y Knight
2019-07-10 20:11 ` A. Wilcox
2019-07-10 20:19 ` Michael Everitt
2019-07-10 20:45 ` Rich Felker
2019-07-10 20:48 ` Rich Felker
2019-07-10 21:11 ` Szabolcs Nagy
2019-07-10 21:16 ` Rich Felker [this message]
2019-07-10 21:44 ` Szabolcs Nagy
2019-07-10 16:01 ` James Y Knight
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=20190710211624.GX1506@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).