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

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #5)
> Even if we look through macros, I'd actually think we should warn here.

I think we should NOT look through macros. The purpose of the warning is to
catch mistakes like xxx && !!xxx or 0 < A || A > 0, but if the user writes f()
&& g() and both functions return the same value, it is clearly not a bug, even
if GCC knows that they are the same function. For the purposes of this warning
(and probably several others), we should treat macros as variables and
functions. Thus,

(errno == EAGAIN || errno == EWOULDBLOCK) /* no warning: EAGAIN and EWOULDBLOCK
are not the same macro */

(errno == EAGAIN || EAGAIN == errno) /* warn:  logical 'or' of the same
expressions */


Of course, this is not trivial to implement at the moment (mostly because we
don't have locations for macros that expand to constants, thus even finding
that something comes from a macro is not possible in most cases).

Reply via email to