}
#endif
+void
+__attribute__ ((noinline))
+test12 (unsigned off)
+{
+ char *buf2 = malloc (10);
+ char *p;
+ size_t t;
+
+ p = &buf2[off];
+
+#ifdef __builtin_object_size
+ if (__builtin_object_size (p, 0) != 10 - off)
+ FAIL ();
+#else
+ if (__builtin_object_size (p, 0) != 10)
+ FAIL ();
+#endif
+}
+
int
main (void)
{
#ifndef SKIP_STRNDUP
test11 ();
#endif
+ test12 (0);
+ test12 (2);
DONE ();
}
return false;
/* Handle PTR + OFFSET here. */
- if (size_valid_p (op1, object_size_type)
- && (TREE_CODE (op0) == SSA_NAME || TREE_CODE (op0) == ADDR_EXPR))
+ if ((TREE_CODE (op0) == SSA_NAME || TREE_CODE (op0) == ADDR_EXPR))
{
if (TREE_CODE (op0) == SSA_NAME)
{
;
else if ((object_size_type & OST_DYNAMIC)
|| bytes != wholesize
- || compare_tree_int (op1, offset_limit) <= 0)
+ || (size_valid_p (op1, object_size_type)
+ && compare_tree_int (op1, offset_limit) <= 0))
bytes = size_for_offset (bytes, op1, wholesize);
/* In the static case, with a negative offset, the best estimate for
minimum size is size_unknown but for maximum size, the wholesize is a