From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 1D3B33858D28 for ; Fri, 31 Mar 2023 22:12:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D3B33858D28 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-wm1-x332.google.com with SMTP id o24-20020a05600c511800b003ef59905f26so14736199wms.2 for ; Fri, 31 Mar 2023 15:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; t=1680300744; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZaZMu6Gnl6qpWK/XQp+w2YpzXYFga+Ln2GrYeipVlKU=; b=VvqmBuU6sGVsFE8aISoSHqnHYQZkjulcAenAMhb/YEnIzQCnFBB0Cl7pRUTRhZAtiO dcOqgQOhQcZCE33IqlZ9lQ1aHEwln06hBhv8IVWqfp4l6OL/6Dt1zNZGIYTSR375trFi SgCBQCy6a9X0JfCCKtU16m/quVklTv8wdpCUxVl+rS+ozrUJjM+qPBYFho65JwmOYkR+ Fclrg1iH2qBiZnBVr8FP1TU4wv4ZzvZdY4p2VgwVYbJRd0qtiAMjtR2JqiukxdrdNchS 3vAN7gtV5yU/FOfhcttw3dhJ+WoYYgUBmDMNBQ3OBHPMzzEmMyrbsKXfppzI7ZPORCTI VJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680300744; h=content-transfer-encoding:in-reply-to:from:references: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=ZaZMu6Gnl6qpWK/XQp+w2YpzXYFga+Ln2GrYeipVlKU=; b=afbRs67FeUC9jvRjR7iMBVqcKHZXuMZqYFgZ2AaEnZxaxQi1AE3icLPUSDcCd6q2Zb DyDLvIwU1lG1waByxDVN5fMPJ9zkWA4VO47Powf94h4SOXmyaMyqecTVKiyWBYMeeFjg mbjTBCn7s+2lTDNnIcVmUlQFLDxB8Ze6jtVsUhca4F5oFLNuiQ7eJnxiax6UZnlBomL9 FS2DFVtVrVpoBDJebNQmDtQ61H5umpFlG9QqI0+UsFoYx8s6YwaobVtgiykDAU241IYN w6pHOvhIp/ubj3UuZILAz4add02x7iROn3C93qpTTwQDxMsSMx3dqyOnNIQx+tlI3uUO UDsw== X-Gm-Message-State: AO0yUKXQHvH4Guk23rhsrbYeI41DlMAJglvcCAWKez2jZwlQDIWpwIpc S6JiRmEm1XRIRaQwlvrZFLPrDJOKDSZFKhOnums= X-Google-Smtp-Source: AK7set/mEUYjJoEiPRQKDiIzpAD08BV1gcN7EjftdLfUUyaTwPZEhhgvR7PX6E3IaUV1d0i8EzGnRQ== X-Received: by 2002:a1c:7207:0:b0:3ed:2606:d236 with SMTP id n7-20020a1c7207000000b003ed2606d236mr20894826wmc.38.1680300743846; Fri, 31 Mar 2023 15:12:23 -0700 (PDT) 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 c1-20020a05600c0a4100b003ee5fa61f45sm11734582wmq.3.2023.03.31.15.12.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Mar 2023 15:12:23 -0700 (PDT) Message-ID: Date: Fri, 31 Mar 2023 23:12:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: __attribute__ error ("message") Content-Language: en-GB To: Xi Ruoyao , gcc-help References: <6dc16e33-647e-5bf5-4025-3e10141aaa66@jguk.org> From: Jonny Grant In-Reply-To: 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 31/03/2023 22:58, Xi Ruoyao wrote: > On Fri, 2023-03-31 at 22:54 +0100, Jonny Grant wrote: >> If the error or warning attribute is used on a function declaration >> and a call to such a function is not eliminated through dead code >> elimination or other optimizations, an error or warning (respectively) >> that includes message is diagnosed. > > In this example the "call to such a function" is clearly "eliminated > through" inlining (one of "other optimizations"). > >> https://godbolt.org/z/n849GPTjj > ok yes, now I understand. The compile_abort() got inlined as abort(). compile_abort(): pushq %rax call abort main: pushq %rax call abort So if I implement it, I must avoid it being optimized (using pragma etc as below) Or do as Jonathan Wakely suggested, and just remove the implementation. #pragma GCC push_options #pragma GCC optimize ("O0") void compile_abort() { } #pragma GCC pop_options