From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 624F73858D1E for ; Mon, 20 Feb 2023 11:29:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 624F73858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 31KBSdBg016454; Mon, 20 Feb 2023 05:28:39 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 31KBSdfo016451; Mon, 20 Feb 2023 05:28:39 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 20 Feb 2023 05:28:38 -0600 From: Segher Boessenkool To: Marc Glisse via Gcc-help Cc: Gabriel Ravier , Marc Glisse , Xi Ruoyao , Jonathan Wakely , Jonny Grant Subject: Re: std::string add nullptr attribute Message-ID: <20230220112838.GO25951@gate.crashing.org> References: <6b530d67-723a-a0c9-15bc-12b7341653a7@jguk.org> <96f99315a6ffd3dd3919b23a4ade2597747a580a.camel@xry111.site> <1e62a6f51b748454abe88438f2040486722c5803.camel@xry111.site> <7e54f0b6-0c58-e340-46a3-b46fa321a201@inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e54f0b6-0c58-e340-46a3-b46fa321a201@inria.fr> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Feb 20, 2023 at 12:18:36PM +0100, Marc Glisse via Gcc-help wrote: > On Mon, 20 Feb 2023, Gabriel Ravier via Gcc-help wrote: > > >This is the kind of thing that makes me wonder why there isn't some kind > >of `__builtin_unreachable_do_not_optimize()` builtin that allows one to > >mark places in code that should never be reached and should thus be warned > >about if such a thing happens while at the same time never doing any > >optimization on the basis of the presence of the call. > > -fsanitize=unreachable -fsanitize=null and others prevent the kind of > optimization you are worried about. Or even just __builtin_trap(), or abort(), or similar. Just a printf() thing if you really want to just warn. "Never doing any optimisation" based on is of course not a reasonable expectation; but you *can* ask for reachable code not to be optimised away. This is the default, just don't mark reachable code as unreachable :-) Segher