From: Jakub Jelinek Date: Tue, 20 Jun 2017 07:22:31 +0000 (+0200) Subject: tree-chkp.c (chkp_get_hard_register_var_fake_base_address): Rewritten to avoid overfl... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e36bb52a85446a759c7f7131048db1ca3236eb7;p=gcc.git tree-chkp.c (chkp_get_hard_register_var_fake_base_address): Rewritten to avoid overflow for > 32-bit pointers. * tree-chkp.c (chkp_get_hard_register_var_fake_base_address): Rewritten to avoid overflow for > 32-bit pointers. From-SVN: r249398 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 331e1a49e68..d46daf3d93e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,7 @@ -2017-06-20 Jakub Jelinek +2017-07-20 Jakub Jelinek + + * tree-chkp.c (chkp_get_hard_register_var_fake_base_address): + Rewritten to avoid overflow for > 32-bit pointers. PR sanitizer/81125 * ubsan.h (ubsan_encode_value): Workaround buggy clang++ parser diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index ecac901d52b..e241f50f308 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -690,9 +690,8 @@ chkp_erase_completed_bounds (void) static tree chkp_get_hard_register_var_fake_base_address () { - tree base = fold_convert (ptr_type_node, integer_zero_node); - unsigned HOST_WIDE_INT offset = 1 << (TYPE_PRECISION (ptr_type_node) - 1); - return fold_build_pointer_plus_hwi (base, offset); + int prec = TYPE_PRECISION (ptr_type_node); + return wide_int_to_tree (ptr_type_node, wi::min_value (prec, SIGNED)); } /* If we check bounds for a hard register variable, we cannot