From 05a647564aab92f73fc28631a1bb0311ee8f38f9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 2 Sep 2016 02:14:50 +0000 Subject: PR tree-optimization/71831 - __builtin_object_size poor results with no PR tree-optimization/71831 - __builtin_object_size poor results with no optimization gcc/testsuite/ChangeLog: PR tree-optimization/71831 * gcc.dg/builtin-object-size-16.c: New test. * gcc.dg/builtin-object-size-17.c: New test. gcc/ChangeLog: PR tree-optimization/71831 * tree-object-size.h: Return bool instead of the size and add argument for the size. * tree-object-size.c (compute_object_offset): Update signature. (addr_object_size): Same. (compute_builtin_object_size): Return bool instead of the size and add argument for the size. Handle POINTER_PLUS_EXPR when optimization is disabled. (expr_object_size): Adjust. (plus_stmt_object_size): Adjust. (pass_object_sizes::execute): Adjust. * builtins.c (fold_builtin_object_size): Adjust. * doc/extend.texi (Object Size Checking): Update. * ubsan.c (instrument_object_size): Adjust. From-SVN: r239953 --- gcc/ubsan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/ubsan.c') diff --git a/gcc/ubsan.c b/gcc/ubsan.c index a118af2..5cbc98d 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1826,8 +1826,8 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs) if (decl_p) base_addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (base)), base); - unsigned HOST_WIDE_INT size = compute_builtin_object_size (base_addr, 0); - if (size != HOST_WIDE_INT_M1U) + unsigned HOST_WIDE_INT size; + if (compute_builtin_object_size (base_addr, 0, &size)) sizet = build_int_cst (sizetype, size); else if (optimize) { -- cgit v1.1