This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations
- From: "miyuki at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 18 Jun 2015 01:05:41 +0000
- Subject: [Bug c++/66572] [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations
- Auto-submitted: auto-generated
- References: <bug-66572-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66572
--- Comment #3 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
Started with r222408. The commit message says:
PR c/63357
* c-common.c (warn_logical_operator): Warn if the operands have the same
expressions.
* doc/invoke.texi: Update description of -Wlogical-op.
Apperntly, the warning about same expressions in a logical expression was added
to Wlogical-op after GCC 5.1 release (I didn't know that) and it had this
problem from the very beginning.
In warn_logical_operator we have a check:
/* We do not warn for constants because they are typical of macro
expansions that test for features. */
if (CONSTANT_CLASS_P (op_left) || CONSTANT_CLASS_P (op_right))
return;
But in this case op_left and op_right are:
<var_decl 0x7ffff6118bd0 value
type <boolean_type 0x7ffff6263888 bool readonly public unsigned QI
size <integer_cst 0x7ffff610bf48 constant 8>
unit size <integer_cst 0x7ffff610bf60 constant 1>
align 8 symtab 0 alias set -1 canonical type 0x7ffff6263888 precision 1
min <integer_cst 0x7ffff612e1b0 0> max <integer_cst 0x7ffff612e1e0 1>>
I think it's still possible to fix this check to handle C++ boolean constants
properly (as if they were literal constants). But for general case we probably
must somehow know (e.g. add a new flag to enum tsubst_flags and pass it to
warn_logical_operator from build_new_op_1), that current expression depends on
template parameter.