This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]