On Thu, 31 Mar 2022 at 17:03, Marc Glisse via Libstdc++ <libstd...@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?