This is the mail archive of the gcc-bugs@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]

[Bug c/70477] -Wtautological-compare too aggressive?


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70477

Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #6 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
(In reply to ecloud from comment #5)
> If a macro exists in order to test something and generate different code
> depending on the test result, then in any given use case of the macro, we
> can say that the test inside the macro is a tautology, right?  But that
> shouldn't mean that doing tests inside macros is bad.

We want to avoid warning for macros in general because of that, and we already
avoid some cases. However, GCC can only detect that something comes from a
macro if it expands to something for which GCC tracks locations. GCC currently
does not track locations for constants (0), variable-uses (x) and some simple
expressions that may get folded too early. So if you have !!0 or 0 != 1, GCC
right now cannot tell whether this is the result of macro expansion (at the
point of warning).

It is not likely that the bug will get fixed in the near term, so if you think
that you may still want this warning in general, a work-around is to disable
this warning for the relevant line using #pragma GCC diagnostic.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]