public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marc Glisse <marc.glisse@inria.fr>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++ <libstdc++@gcc.gnu.org>,
	Matthias Kretz <m.kretz@gsi.de>,
	 gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: Implement std::unreachable() for C++23 (P0627R6)
Date: Thu, 31 Mar 2022 20:21:32 +0200 (CEST)	[thread overview]
Message-ID: <147e97d-41ab-98d-7721-a6cf2e0ddeb@hippo.saclay.inria.fr> (raw)
In-Reply-To: <CACb0b4k-t6LQo_nGC=+QQwybTnr444m30mioP28Ag8BoLaHQ6A@mail.gmail.com>

On Thu, 31 Mar 2022, Jonathan Wakely wrote:

> On Thu, 31 Mar 2022 at 17:03, Marc Glisse via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
>>
>> On Thu, 31 Mar 2022, Matthias Kretz via Gcc-patches wrote:
>>
>>> I like it. But I'd like it even more if we could have
>>>
>>> #elif defined _UBSAN
>>>    __ubsan_invoke_ub("reached std::unreachable()");
>>>
>>> But to my knowledge UBSAN has no hooks for the library like this (yet).
>>
>> -fsanitize=undefined already replaces __builtin_unreachable with its own
>> thing, so I was indeed going to ask if the assertion / trap provide a
>> better debugging experience compared to plain __builtin_unreachable, with
>> the possibility to get a stack trace (UBSAN_OPTIONS=print_stacktrace=1),
>> etc? Detecting if (the right subset of) ubsan is enabled sounds like a
>> good idea.
>
> Does UBsan define a macro that we can use to detect it?

https://github.com/google/sanitizers/issues/765 seems to say no (it could 
be outdated though), but they were asking for use cases to motivate adding 
one. Apparently there is a macro for clang, although I don't think it is 
fine-grained.

Adding one to cppbuiltin.cc testing SANITIZE_UNREACHABLE looks easy, maybe 
we can do just this one, we don't need to go overboard and define macros 
for all possible suboptions of ubsan right now.

I don't think any of that prevents from pushing your patch as is for 
gcc-12.

-- 
Marc Glisse

  reply	other threads:[~2022-03-31 18:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31 15:30 Jonathan Wakely
2022-03-31 15:50 ` Matthias Kretz
2022-03-31 15:59   ` Xi Ruoyao
2022-03-31 16:01   ` Marc Glisse
2022-03-31 16:05     ` Jonathan Wakely
2022-03-31 18:21       ` Marc Glisse [this message]
2022-04-01 11:33         ` Jonathan Wakely
2022-04-01 11:56           ` Matthias Kretz
2022-04-01 13:01             ` Jonathan Wakely
2022-03-31 16:02   ` Jonathan Wakely

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=147e97d-41ab-98d-7721-a6cf2e0ddeb@hippo.saclay.inria.fr \
    --to=marc.glisse@inria.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=m.kretz@gsi.de \
    /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).