https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863
Bug ID: 67863 Summary: -Wtautological-compare warns when it shouldn't Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- extern int e; #define A (e ? 4 : 8) #define B (e ? 4 : 8) int fn (void) { if (A <= B) return 1; return 0; } cc1plus warns, while cc1 does not. What happens here is that the COND_EXPRs warn_tautological_cmp gets don't have a location in cc1plus: (gdb) pt warning: Expression is not an assignment (and might have no effect) <cond_expr 0x7ffff16fa990 type <integer_type 0x7ffff16ff7e0 int public SI size <integer_cst 0x7ffff171d0a8 constant 32> unit size <integer_cst 0x7ffff171d0c0 constant 4> align 32 symtab 0 alias set -1 canonical type 0x7ffff16ff7e0 precision 32 min <integer_cst 0x7ffff171d060 -2147483648> max <integer_cst 0x7ffff171d078 2147483647> pointer_to_this <pointer_type 0x7ffff1721930>> arg 0 <ne_expr 0x7ffff1853cd0 type <boolean_type 0x7ffff16ffd20 bool public unsigned QI size <integer_cst 0x7ffff16fbf48 constant 8> unit size <integer_cst 0x7ffff16fbf60 constant 1> align 8 symtab 0 alias set -1 canonical type 0x7ffff16ffd20 precision 1 min <integer_cst 0x7ffff171d1b0 0> max <integer_cst 0x7ffff171d1e0 1>> arg 0 <var_decl 0x7ffff1707bd0 e type <integer_type 0x7ffff16ff7e0 int> used public external decl_2 SI file b.c line 1 col 12 size <integer_cst 0x7ffff171d0a8 32> unit size <integer_cst 0x7ffff171d0c0 4> align 32 context <translation_unit_decl 0x7ffff7ff91e0 D.1> chain <function_decl 0x7ffff1854c40 __cxa_call_unexpected>> arg 1 <integer_cst 0x7ffff171d1f8 constant 0>> arg 1 <integer_cst 0x7ffff171d588 type <integer_type 0x7ffff16ff7e0 int> constant 4> arg 2 <integer_cst 0x7ffff186ac30 type <integer_type 0x7ffff16ff7e0 int> constant 8>> in cc1: (gdb) pt warning: Expression is not an assignment (and might have no effect) <cond_expr 0x7ffff1828b70 type <integer_type 0x7ffff16ff7e0 int public SI size <integer_cst 0x7ffff16fbee8 constant 32> unit size <integer_cst 0x7ffff16fbf00 constant 4> align 32 symtab 0 alias set -1 canonical type 0x7ffff16ff7e0 precision 32 min <integer_cst 0x7ffff16fbea0 -2147483648> max <integer_cst 0x7ffff16fbeb8 2147483647> pointer_to_this <pointer_type 0x7ffff1719930>> arg 0 <ne_expr 0x7ffff182b050 type <integer_type 0x7ffff16ff7e0 int> arg 0 <c_maybe_const_expr 0x7ffff182b028 type <integer_type 0x7ffff16ff7e0 int> arg 1 <var_decl 0x7ffff1707c60 e>> arg 1 <integer_cst 0x7ffff1718048 constant 0> b.c:8:7> arg 1 <integer_cst 0x7ffff1718330 type <integer_type 0x7ffff16ff7e0 int> constant 4> arg 2 <integer_cst 0x7ffff18191e0 type <integer_type 0x7ffff16ff7e0 int> constant 8> b.c:8:7>