Hi Jason,

The commit

Shorten right-shift again in C++.

Back in SVN r131862 richi removed this code to fix PR 34235, but didn't
remove the parallel code from the C front-end because the bug had previously
been fixed in r44080.  This patch copies the code from C again.

        * typeck.c (cp_build_binary_op): Restore short_shift code.

From-SVN: r280128

Is causing ICEs in SPEC2017's leela.

internal compiler error: tree check: expected integer_cst, have mult_expr in 
to_wide, at tree.h:5860
  368 |         int allblack = ((m_neighbours[i] >> (NBR_SHIFT * BLACK)) & 7) 
== 4;
      |                                                               ^
0x6565d3 tree_check_failed(tree_node const*, char const*, int, char const*, ...)
        ../.././gcc/tree.c:9685
0x11d3d33 tree_int_cst_elt_check(tree_node*, int, char const*, int, char const*)
        ../.././gcc/tree.h:3478
0x11d3d33 tree_int_cst_elt_check(tree_node const*, int, char const*, int, char 
const*)
        ../.././gcc/tree.h:3474
0x11d3d33 wi::to_wide(tree_node const*)
        ../.././gcc/tree.h:5860
0x11d3d33 tree_int_cst_sgn(tree_node const*)
        ../.././gcc/tree.c:7382
0x90ad8f cp_build_binary_op(op_location_t const&, tree_code, tree_node*, 
tree_node*, int)
        ../.././gcc/cp/typeck.c:5609
0x681547 build_new_op_1
        ../.././gcc/cp/call.c:6475
0x681fdf build_new_op(op_location_t const&, tree_code, int, tree_node*, 
tree_node*, tree_node*, tree_node**, int)
        ../.././gcc/cp/call.c:6520
0x8f960f build_x_binary_op(op_location_t const&, tree_code, tree_node*, 
tree_code, tree_node*, tree_code, tree_node**, int)
        ../.././gcc/cp/typeck.c:4245
0x7dc7cf cp_parser_binary_expression
        ../.././gcc/cp/parser.c:9648
0x7ddb1f cp_parser_assignment_expression
        ../.././gcc/cp/parser.c:9783
0x7dde3b cp_parser_expression
        ../.././gcc/cp/parser.c:9951
0x7f095f cp_parser_primary_expression
        ../.././gcc/cp/parser.c:5351
0x7fdefb cp_parser_postfix_expression
        ../.././gcc/cp/parser.c:7203
0x7dc607 cp_parser_binary_expression
        ../.././gcc/cp/parser.c:9483
0x7ddb1f cp_parser_assignment_expression
        ../.././gcc/cp/parser.c:9783
0x7dde3b cp_parser_expression
        ../.././gcc/cp/parser.c:9951
0x7f095f cp_parser_primary_expression
        ../.././gcc/cp/parser.c:5351
0x7fdefb cp_parser_postfix_expression
        ../.././gcc/cp/parser.c:7203
0x7dc607 cp_parser_binary_expression
        ../.././gcc/cp/parser.c:9483

Thanks,
Tamar

> -----Original Message-----
> From: gcc-patches-ow...@gcc.gnu.org <gcc-patches-ow...@gcc.gnu.org>
> On Behalf Of Jason Merrill
> Sent: Friday, January 10, 2020 6:15 PM
> To: gcc-patches List <gcc-patches@gcc.gnu.org>; Joseph S. Myers
> <jos...@codesourcery.com>
> Cc: Manuel López-Ibáñez <m...@gcc.gnu.org>
> Subject: [RFC c-common PATCH] PR c++/40752 - useless -Wconversion with
> short +=.
> 
> Back in 2009 Manuel sent a patch to avoid useless -Wconversion warnings on
> compound assignment of types that get promoted to int:
> 
> https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00582.html
> 
> Joseph argued that those warnings are sometimes useful, and that they
> should be controlled by a separate flag.  So this patch introduces -Warith-
> conversion, which is off by default in this patch.
> 
> Joseph, is that default OK with you?  If not, can you explain your reasoning
> more about why the warnings are desirable?  It seems to me that even in
> cases where you don't know the ranges involved, it's wrong for e.g. 'mychar
> += 1' to warn when 'myint += 1' doesn't.  In both cases, the addition might
> overflow the range of the target type, but that isn't about the conversion;
> the result is the same as if the operation had been done in the
> operand/target type rather than the promoted type.
> 
> The change to cp/typeck.c is a placeholder to use if the default setting
> changes; even if we end up warning by default for mychar = mychar + 1, I
> really don't want to warn about mychar += 1.
> 
> sign.diff is a prerequisite tidying that moves the warnings from
> unsafe_conversion_p back into conversion_warning with the others.
> 
> rshift.diff restores the short_shift code to the C++ front end so that C and
> C++ give the same warnings with -Warith-conversion.
> 
> Tested x86_64-pc-linux-gnu.  Comments?

Reply via email to