This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/77293] __builtin_object_size inconsistent for multidimensional arrays
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 19 Aug 2016 07:22:29 +0000
- Subject: [Bug middle-end/77293] __builtin_object_size inconsistent for multidimensional arrays
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-77293-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77293
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |64715
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well, for N == 1 the early object-size pass computes 1 as size which means,
as it is supposed to be conservative, the closest surrounding subobject is
the higher-ranked subarray. For N == a you get another conservative answer.
Early object-size can't put a constraint to it and then folding makes
a "mess" out of the address computation:
<bb 2>:
__builtin_memcpy (&MEM[(void *)&x2x3 + 2B], "abc", 4);
return 0;
in ccp1. To "fix" the simple case one could teach the objsz pass to lookup
the definition for a (and thus see the constant 1). Or for example
integrate early objsz with CCP1 and apply things before applying the final
lattice.
I've repeatedly said the design of __builtin_object_size conflicts with the
desire to optimize -- one would need to preserve the original shape of the
access.
But only in some cases it seems. There is an old bug about this, PR64715.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64715
[Bug 64715] [5/6/7 Regression] __builtin_object_size (..., 1) fails to locate
subobject