From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sourceware.org (Postfix) with ESMTPS id F18763857034; Thu, 31 Mar 2022 18:21:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F18763857034 X-IronPort-AV: E=Sophos;i="5.90,225,1643670000"; d="scan'208";a="10216256" Received: from 85-171-189-19.rev.numericable.fr (HELO hippo) ([85.171.189.19]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 20:21:33 +0200 Date: Thu, 31 Mar 2022 20:21:32 +0200 (CEST) From: Marc Glisse To: Jonathan Wakely cc: libstdc++ , Matthias Kretz , gcc Patches Subject: Re: [PATCH] libstdc++: Implement std::unreachable() for C++23 (P0627R6) In-Reply-To: Message-ID: <147e97d-41ab-98d-7721-a6cf2e0ddeb@hippo.saclay.inria.fr> References: <20220331153029.1898244-1-jwakely@redhat.com> <3572914.e9J7NaK4W3@minbar> <48cc3e77-8f70-a4a7-ad16-22ba11d883b4@grove.saclay.inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2022 18:21:36 -0000 On Thu, 31 Mar 2022, Jonathan Wakely wrote: > On Thu, 31 Mar 2022 at 17:03, Marc Glisse via Libstdc++ > 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