This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Counter intuitively, asserts hurt gcc static dataflow analysis.
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: David Brown <david at westcontrol dot com>
- Cc: Segher Boessenkool <segher at kernel dot crashing dot org>, Mason <slash dot tmp at free dot fr>, John Carter <john dot carter at taitradio dot com>, GCC help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 9 May 2018 12:54:16 +0100
- Subject: Re: Counter intuitively, asserts hurt gcc static dataflow analysis.
- References: <CAFD1m3FNaL4_T=hwUSi6Li+8P3+WiV8jL=2H_QuziqsE2MX6Ug@mail.gmail.com> <da589209-ee80-5135-1b63-103f4ebaabf2@free.fr> <20180504133440.GW14117@gate.crashing.org> <CAH6eHdS=1HtnXrKC3vGtwT_u6y2mYsiPTKpYv9SXKb9Ko_X1kQ@mail.gmail.com> <5AF2C9CE.5030208@westcontrol.com> <CAH6eHdRLAaSBu=7eVsc9XSkOCpyqHggtLpFerCWHsCgAHuyh=g@mail.gmail.com> <5AF2D08A.9000501@westcontrol.com>
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.