On Mon, 30 Mar 2020 at 06:54, Daniel Brodsky <dnbrd...@gmail.com> wrote:

> Using `#pragma clang diagnostic ignored
> "-Wtautological-type-limit-compare"` suppresses the errors (on Clang
> 9). I could go and drop that in for the problem areas? There's only a
> few so it wouldn't be a major change. I'm thinking of adding a macro
> like this:
> #define PRAGMA(x) _Pragma(stringify(x))
> #define IF_IGNORE_TYPE_LIMIT(statement) \
>         PRAGMA(clang diagnostic push) \
>         PRAGMA(clang diagnostic ignored "-Wtautological-type-limit-compare") \
>         if (statement) \
>         PRAGMA(clang diagnostic pop)

This is not an in-principle objection, but we have found in the past that
various gcc/clang implementations of _Pragma() are simply buggy
when used inside macros; see the comments on this patch attempt:
https://patchwork.kernel.org/patch/10620079/
(one of which has a link to half a dozen gcc bug reports involving
_Pragma and three clang bugs). For that particular case the approach
we eventually took was to only use the _Pragma() stuff on clang because
gcc mishandled it and luckily the spurious warning was clang-only.
It's a shame, because the whole point of _Pragma() is to let you do
this kind of thing in a macro, but the actual implementations in
compilers are clearly just not fit-for-purpose.

So if you do go down this path please make sure you test it on a
wide variety of different clang and gcc versions.

thanks
-- PMM

Reply via email to