Re: __attribute__ error ("message")

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)).

> 
> 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

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux