Re: [PATCH 2/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2
Nathan Chancellor <[email protected]>
| Newsgroups | org.kernel.vger.linux-api,dev.linux.lists.patches,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.netdev,org.kvack.linux-mm |
|---|---|
| Message-ID | <20260605015724.GA520134@ax162> |
On Thu, Jun 04, 2026 at 10:32:16PM +0100, David Laight wrote:
> Talking of broken compilers, had you noticed that:
> struct foo {
> int a;
> char c[32];
> };
>
> int b(struct foo *f)
> {
> return __builtin_object_size(f->c, 1);
> }
> returns -1 (size unknown/indefinite).
> You can't use __builtin_object_size() to stop code running off the end
> of anything referenced by address - even when the size is constant.
That is the entire point of using '-fstrict-flex-arrays=3' in the
kernel:
df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3")
https://godbolt.org/z/bvfrh7W58
Without it, all trailing arrays in structures are treated as flexible
arrays, even those with fixed sizes.
--
Cheers,
Nathan