From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 1E71B385840E for ; Mon, 20 Feb 2023 11:44:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E71B385840E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=jguk.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jguk.org Received: by mail-wr1-x430.google.com with SMTP id o4so845832wrs.4 for ; Mon, 20 Feb 2023 03:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9dLioLOkUpcQN8h03aF+E4FWpwdAUuX2vqkwf+33XK4=; b=LcWuAOTi99fOjkNjk8dcG20MUpXrfB5eE4Ak76CycKALXllrk+EnFwU3pQ3AbJ7saq 7ocJgLAJAbT7p+Gk/cMGS4opVE8pcM3VX5XYPqf+MuJrpL81Di/rgS3R5bON2WS7+htx p0S9XhowQ7uoCcIYOOLMyfcW3b4W6xN1Wesy9qWLs7HyCfSv+48P/L9Sbv2eKJEJU8JR 969of9JZ4sCcLZjuGl/1DXpZ+ywZqk4pzVlTJ1quRgR0ITFM/nDKGuJdo1pu9QGEzAzi PWFEfR05iVUIBkRsloGu3AuEw9/JOLohdGFnOG/mdXACofnNNVl0ZzAt82ngHi3K91Ac E1dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9dLioLOkUpcQN8h03aF+E4FWpwdAUuX2vqkwf+33XK4=; b=2zrIdbL0TKY2kWamfyK5h4fzpYpQxsRlCesixyt4UJcydJHL8Hu41/ME4AADqnRi1P m/5AoYbWWMxb6Dnx9/lThVzLDER2qnhZ3YzKenBIPYsO2ypV0hADYqziDYF168MB5sgD IEIn3Yp+aFlY6G+djsUzQ7I9wYgz//b3Wh/flbzOtBTr9IEitSmZAzqIf3ke5eCOqcoA qsBfKAdO2UwFsPexIptZr2LjmK3DoYyDgbDdgxvj4cZqZ261hwhKtXN6oxjJvikavDTx m7dwogWj5l0/qpaFF+vf3bmuYzhUQ2km8t8JghXito6EyGfPKuxIRI4Pl4KHhS0WXwFf U9fg== X-Gm-Message-State: AO0yUKWE1t97VTTjSsDGw7yq1O2bB8tDH0XTm1uxNy9UTS180ixgaIw7 pCeFOmNP3+1PngjNa+Upn94/jpKmm0nXgu9p X-Google-Smtp-Source: AK7set+w+VDmzHy8MPU578wvKXRoSu9ItjF79zUmGA6JYO99YKMaN/lNJ19aMVdJCNQA0Ewv4eQa0A== X-Received: by 2002:adf:e64d:0:b0:2c5:6cfe:aabf with SMTP id b13-20020adfe64d000000b002c56cfeaabfmr1135862wrn.9.1676893472792; Mon, 20 Feb 2023 03:44:32 -0800 (PST) Received: from [192.168.0.12] (cpc87345-slou4-2-0-cust172.17-4.cable.virginm.net. [81.101.252.173]) by smtp.gmail.com with ESMTPSA id l18-20020a5d4112000000b002c56179d39esm3114977wrp.44.2023.02.20.03.44.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Feb 2023 03:44:32 -0800 (PST) Message-ID: <8e65f974-daab-0b17-472a-4ee679885174@jguk.org> Date: Mon, 20 Feb 2023 11:44:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: std::string add nullptr attribute Content-Language: en-GB To: gcc-help@gcc.gnu.org, Gabriel Ravier Cc: Xi Ruoyao , Jonathan Wakely References: <7e6e3bbf-0dac-0632-0e8f-372bd32a6923@jguk.org> <6e30ed8e6c6f08407a5b8259e73fd18a492376b5.camel@xry111.site> <8cfbab8b-07e8-7dab-c829-6de77cc8cf39@jguk.org> <6b530d67-723a-a0c9-15bc-12b7341653a7@jguk.org> <96f99315a6ffd3dd3919b23a4ade2597747a580a.camel@xry111.site> <1e62a6f51b748454abe88438f2040486722c5803.camel@xry111.site> <7e54f0b6-0c58-e340-46a3-b46fa321a201@inria.fr> From: Jonny Grant In-Reply-To: <7e54f0b6-0c58-e340-46a3-b46fa321a201@inria.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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 20/02/2023 11:18, Marc Glisse 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. > Unfortunately santizer is only at runtime. I'm seeking build time warnings. Sharing my example: https://godbolt.org/z/c7b17nMGd Execution build compiler returned: 0 Program returned: 139 /app/example.cpp:4:10: runtime error: load of null pointer of type 'const char' Regards, Jonny