aboutsummaryrefslogtreecommitdiff
path: root/gcc/vec.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-10-27 10:24:45 +0200
committerJakub Jelinek <jakub@redhat.com>2022-10-27 10:24:45 +0200
commitbfb7994a9fb0b10767d12b8d670c081014ad8b01 (patch)
tree8b773de99527a8b9d6fe5bfe7ed5d253e07d5538 /gcc/vec.h
parent4e1d704243a4f3c4ded47cd0d02427bb7efef069 (diff)
downloadgcc-bfb7994a9fb0b10767d12b8d670c081014ad8b01.zip
gcc-bfb7994a9fb0b10767d12b8d670c081014ad8b01.tar.gz
gcc-bfb7994a9fb0b10767d12b8d670c081014ad8b01.tar.bz2
c++: Fix excess precision related ICE on invalid binop [PR107382, PR107383]
The following tests ICE in the gcc_assert (common); in cp_build_binary_op. I've missed that while for * common is set always, while for +, - and / it is in some cases not. If it is not, then if (!result_type && arithmetic_types_p && (shorten || common || short_compare)) condition is false, then the following if (may_need_excess_precision && (orig_type0 != type0 || orig_type1 != type1) && build_type == NULL_TREE) would fail the assertion there and if there wouldn't be excess precision, if (code == SPACESHIP_EXPR) would be false (for SPACESHIP_EXPR we always have build_type set like for other comparisons) and then trigger if (!result_type) { if (complain & tf_error) { binary_op_rich_location richloc (location, orig_op0, orig_op1, true); error_at (&richloc, "invalid operands of types %qT and %qT to binary %qO", TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), code); } return error_mark_node; } So, if result_type is NULL, we don't really need to compute semantic_result_type because nothing will use it anyway and can get fall through into the error/return error_mark_node; case. 2022-10-27 Jakub Jelinek <jakub@redhat.com> PR c++/107382 PR c++/107383 * typeck.cc (cp_build_binary_op): Don't compute semantic_result_type if result_type is NULL. * g++.dg/diagnostic/bad-binary-ops2.C: New test.
Diffstat (limited to 'gcc/vec.h')
0 files changed, 0 insertions, 0 deletions