Hi,
On 2023-02-05 10:18:14 +0900, Michael Paquier wrote:
> On Sat, Feb 04, 2023 at 05:07:08AM -0800, Andres Freund wrote:
> > <source>: In function 'assign':
> > <source>:9:6: warning: array subscript 'foo[0]' is partly outside array bounds of 'unsigned char[4]'
[-Warray-bounds=]
> > 9 | p->i = i;
> > | ^~
> > <source>:8:22: note: object of size 4 allocated by '__builtin_malloc'
> > 8 | foo *p = (foo *) __builtin_malloc(sizeof(int));
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Compiler returned: 0
> >
> > I can't really tell if gcc is right or wrong wrong to warn about
> > this. On the one hand it's a union, and we only access the element that
> > is actually backed by memory, on the other hand, the standard does say
> > that the size of a union is the largest element, so we are pointing to
> > something undersized.
>
> Something I have noticed, related to that.. meson reports a set of
> warnings here, not ./configure, still I apply the same set of CFLAGS
> to both. What's the difference in the meson setup that creates that,
> if I may ask? There is a link to the way -Warray-bound is handled?
It's possibly related to the optimization level used. Need a bit more
information to provide a more educated guess. What warnings, what CFLAGS
etc.
Greetings,
Andres Freund