https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77434
Bug ID: 77434 Summary: warn about suspicious precedence of ternary operator (?:) Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: manu at gcc dot gnu.org Target Milestone: --- Code such as the following are suspicious: int foo(int a, int b) { return (a > 0 && a <= (b == 1) ? 1 : 2); } some users may expect it to be equivalent to a <= ((b==1) ? 1 :2) but it is in fact equivalent to (a <= (b == 1)) ? 1 : 2 We should warn with -Wparenthesis Real bug in GCC: PR77421 static void output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip) { unsigned long die_offset = get_ref_die_offset (val1->v.val_die_ref.die); .... gcc_assert (die_offset > 0 && die_offset <= (loc->dw_loc_opc == DW_OP_call2) ? 0xffff : 0xffffffff); .... }