From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: undersized unions |
Date: | 2023-02-05 12:44:15 |
Message-ID: | 20230205124415.bhquffioa4rvaplx@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2023-02-05 14:29:08 | Re: run pgindent on a regular basis / scripted manner |
Previous Message | Alvaro Herrera | 2023-02-05 12:10:47 | Re: First draft of back-branch release notes is done |