public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH] c: Implement C23 nullptr (N3042)
Date: Wed, 24 Aug 2022 14:24:32 -0400	[thread overview]
Message-ID: <YwZs4KbOWvLirbQB@redhat.com> (raw)
In-Reply-To: <38054995-48c3-8e98-623a-c2057ec70fb3@redhat.com>

On Mon, Aug 15, 2022 at 04:03:13PM -0400, Jason Merrill wrote:
> On 8/13/22 14:35, Marek Polacek wrote:
> > This patch implements the C23 nullptr literal:
> > <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3042.htm>, which is
> > intended to replace the problematic definition of NULL which might be
> > either of integer type or void*.
> > 
> > Since C++ has had nullptr for over a decade now, it was relatively easy
> > to just move the built-in node definitions from the C++ FE to the C/C++
> > common code.  Also, our DWARF emitter already handles NULLPTR_TYPE by
> > emitting DW_TAG_unspecified_type.  However, I had to handle a lot of
> > contexts such as ?:, comparison, conversion, etc.
> > 
> > There are some minor differences, e.g. in C you can do
> > 
> >    bool b = nullptr;
> > 
> > but in C++ you have to use direct-initialization:
> > 
> >    bool b{nullptr};
> > 
> > And I think that
> > 
> >    nullptr_t n = 0;
> > 
> > is only valid in C++.
> > 
> > Of course, C doesn't have to handle mangling, RTTI, substitution,
> > overloading, ...
> > 
> > This patch also defines nullptr_t in <stddef.h>.  I'm uncertain about
> > the __STDC_VERSION__ version I should be checking.  Also, I'm not
> > defining __STDC_VERSION_STDDEF_H__ yet, because I don't know what value
> > it should be defined to.  Do we know yet?
> > 
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> 
> The C++ changes are OK, but you probably want a comment in
> c_common_nodes_and_builtins that we aren't setting the alignment there for
> C++ backward ABI bug compatibility.  Or perhaps set it there and then break
> it in the C++ front end when abi < 9.

Thanks!  I added a comment to that effect in the v2 patch I just posted.

Marek


      reply	other threads:[~2022-08-24 18:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-13 21:35 Marek Polacek
2022-08-15 17:48 ` Joseph Myers
2022-08-24 18:24   ` [PATCH v2] " Marek Polacek
2022-08-25 17:28     ` Joseph Myers
2022-08-25 20:51       ` [PATCH v3] " Marek Polacek
2022-08-25 21:12         ` Joseph Myers
2022-08-25 22:14           ` Marek Polacek
2022-08-15 20:03 ` [PATCH] " Jason Merrill
2022-08-24 18:24   ` Marek Polacek [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=YwZs4KbOWvLirbQB@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).