[Bug sanitizer/83392] FAIL: c-c++-common/ubsan/ptr-overflow-sanitization-1.c scan-tree-dump-times
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 13 15:38:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83392
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
When I try to fix this using:
--- gcc/sanopt.c.jj 2018-03-02 00:15:54.670780980 +0100
+++ gcc/sanopt.c 2018-03-13 16:35:38.333020680 +0100
@@ -486,12 +486,17 @@ maybe_optimize_ubsan_ptr_ifn (sanopt_ctx
HOST_WIDE_INT bitpos;
base = get_inner_reference (base, &bitsize, &pbitpos, &offset, &mode,
&unsignedp, &reversep, &volatilep);
- if (offset == NULL_TREE
+ if ((offset == NULL_TREE || TREE_CODE (offset) == INTEGER_CST)
&& DECL_P (base)
&& pbitpos.is_constant (&bitpos))
{
gcc_assert (!DECL_REGISTER (base));
- offset_int expr_offset = bitpos / BITS_PER_UNIT;
+ offset_int expr_offset;
+ if (offset)
+ expr_offset = wi::to_offset (offset) + bitpos / BITS_PER_UNIT;
+ else
+ expr_offset = bitpos / BITS_PER_UNIT;
+ expr_offset = wi::sext (expr_offset, POINTER_SIZE);
offset_int total_offset = expr_offset + cur_offset;
if (total_offset != wi::sext (total_offset, POINTER_SIZE))
{
then ptr-overflow-sanitization-1.c FAILs for -m32 like before (i.e. 14 times,
would need to adjust testcase), but -m64 FAILs 13 times compared to previous 17
times.
More information about the Gcc-bugs
mailing list