Re: Counter intuitively, asserts hurt gcc static dataflow analysis.

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

 



On 9 May 2018 at 11:42, David Brown wrote:
> On 09/05/18 12:31, Jonathan Wakely wrote:
>> IIUC __attribute__((warning("..."))) requires linking to an extern
>> function, which might not be desirable in the general case for assert.
>>
>
> Can you not use this?
>
> static void __attribute__((warning("Smart assert always failed")))
>      __smartAssertAlwaysFail(void) {}

I can't remember if I tried a static function, but it would create ODR
violations in C++ code if inline functions or templates call a static
function, because every translation unit would resolve the call to a
different function. I did try an inline function, and that doesn't
work. It would probably be harmless, but still technically undefined
behaviour.

> (In the case of the error, I see it as an advantage that the error
> function is not defined and will also give a linker error if I somehow
> manage to compile code with the call left in.)

Indeed.



[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