From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 27CF73858D35 for ; Sat, 1 Apr 2023 23:00:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27CF73858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x532.google.com with SMTP id er13so62629909edb.9 for ; Sat, 01 Apr 2023 16:00:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680390035; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=T3PaF2goeJMYaxulmnP3OfQ400TRImctXGH/jeuI0c4=; b=i3aD8buw5CQcUmR91cIZlorLC9Vg9tRGqDFjN+kaCjEH7fOquyfZ8Oe/VhbKBooNmX ku1ZpXtcWi9gjV0yJ1TxZcsJVITMak3SWz6Qs5wpLfl34Huo220fTRLfBDjpnj2fJpyh /Lw1xIgv7qMsvixKWyg34niZVSGl7MyziUA1EbFP0/P+eCh7ptO2AwsOOFQyeqMsvTFS qejAsSFJsRqJLCa05Ry/W9l4YvH5oxcyqfG3Pk0w1+HcMdlnr2DCMe1matuP5ENvFI91 bYkEKczomng3y6sNxugbAT7pK+zts5JLlcawsmE2L4nck7PxmfN+uLSkOx0NIGCUEKKc kTiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680390035; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=T3PaF2goeJMYaxulmnP3OfQ400TRImctXGH/jeuI0c4=; b=Km1qCs0/TLOr01pS2VSXVCl19896YQgeCSpr6i0YZHHNFgILwvuQGn86vOZrue9uG5 4nfv4vp3aYHm62CDrJJyHlsuQ/HqQLk0C6hjpWMxcjB8Vy4/uK6UCr00cg2tJK+sOF8H g39p2DJEUN6E12VBhhNt7eKR55BP2zIf/Zj5Z0dDch935IW8mwoER4GYVPtS2j6gk3Tr xGaORa12BCtNxLXBnAzYEt0q9XLJQn9N87SOzR/DZAeDTUHNo7muAPXEV+mPCao7RflT 5PBMEDUGw0bnck8EAnhNKY4zhhdNHJsqBpeCDSmT3GzlxAVHLomZ/qaHSNtMpMRMud4i U1pg== X-Gm-Message-State: AAQBX9dKQ435NQ3tg3yrxbliv6s6njCbY6EAiri1MM7WEI3YKL5GVtOU 7V/dTlNtBNeHN7ZZ35IwJJDhFuf+kmzTYRKxdSg= X-Google-Smtp-Source: AKy350YLzciQJ+y83wZP3t1F1+b1YL9obC2EuyXKwh9q6xcWaPymH4JDd5H5PLti0Pzbma8/UqpVSaYPUzhExt2UiYU= X-Received: by 2002:a17:906:81da:b0:92f:b329:cb75 with SMTP id e26-20020a17090681da00b0092fb329cb75mr8468380ejx.5.1680390034954; Sat, 01 Apr 2023 16:00:34 -0700 (PDT) MIME-Version: 1.0 References: <6dc16e33-647e-5bf5-4025-3e10141aaa66@jguk.org> <20a625a4400a9ef486bca22be98a293675864b84.camel@xry111.site> <44df96a9-6f86-196f-b126-8b798f1d5696@jguk.org> In-Reply-To: <44df96a9-6f86-196f-b126-8b798f1d5696@jguk.org> From: Jonathan Wakely Date: Sun, 2 Apr 2023 00:00:22 +0100 Message-ID: Subject: Re: __attribute__ error ("message") To: Jonny Grant Cc: Xi Ruoyao , gcc-help Content-Type: multipart/alternative; boundary="0000000000001e1d0005f84e4bed" X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,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: --0000000000001e1d0005f84e4bed Content-Type: text/plain; charset="UTF-8" On Sat, 1 Apr 2023, 17:58 Jonny Grant, wrote: > > > On 31/03/2023 23:13, Xi Ruoyao wrote: > > On Fri, 2023-03-31 at 23:12 +0100, Jonny Grant wrote: > >> > >> > >> 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 just __attribute__((noipa)). > > That's much clearer. > > It does feel a shame the optimizer inlines the function, discarding the > error("message"), before the attribute error("message") can be triggered. > But we can just put that __attribute__((noipa)) at least. > Why provide a definition? Why do you want to define a function that can never be called, because calling it gives an error? --0000000000001e1d0005f84e4bed--