On Mon, Jul 07, 2025 at 09:07:14AM -0400, Siddhesh Poyarekar wrote: > On 2025-07-07 08:48, Jakub Jelinek wrote: > > > The return value of .ACCESS_WITH_SIZE clobbering PTR (that subsequently > > > gets > > > passed to __builtin_dynamic_object_size) should be sufficient to fully > > > prevent the reordering, it shouldn't have to clobber &PTR, I think. > > > > The original use of .ACCESS_WITH_SIZE was designed for FAMs, for those > > it IMHO does the right thing, it is a pass through first arg function > > which attaches size information to the passed as well as returned pointer. > > That pointer is &FAM, so address of the containing structure plus offsetof > > of the FAM first element. > > So that ought to be &a->fam[0] right, and not &a->fam? It means the same > for a FAM, so why not specify it as &a->fam[0] (or simply a->fam)? That will > be consistent with when fam is a pointer.
The only difference between &a->fam[0] and &a->fam is not the value (that is the same), just the type in one case say int *, in the other int [0:] *. At least in GIMPLE pointer conversions are useless, so what exact type of the argument is doesn't matter that much, but it matters e.g. when you're dereferencing it. Now, for int n; int (*p)[n] __attribute__((counted_by(n))); f->p has the int [n] * type, so guess that is what you want to use. Jakub