On 1/20/19 6:29 AM, Bernd Edlinger wrote:
> Hi,
>
>
> I tried to build linux yesterday, and became aware that there are a few
> false-positive warnings with -Waddress-of-packed-member:
>
> struct t {
> char a;
> int b;
> int *c;
> int d[10];
> } __attribute__((packed));
>
> struct t t0;
> struct t *t1;
> struct t **t2;
>
> t2 = &t1;
> i1 = t0.c;
>
> I fixed them quickly with the attached patch, and added a new test case,
> which also revealed a few missing warnings:
>
> struct t t100[10][10];
> struct t (*baz())[10];
>
> t2 = (struct t**) t100;
> t2 = (struct t**) baz();
>
>
> Well I remembered that Joseph wanted me to use min_align_of_type instead
> of TYPE_ALIGN in the -Wcast-align warning, so I changed
> -Waddress-of-packed-member
> to do that as well.
>
> Since I was not sure if the test coverage is good enough, I added a few more
> test cases, which just make sure the existing warning works properly.
>
> I am however not sure of a warning that is as noisy as this one, should be
> default-enabled, because it might interfere with configure tests. That might
> be better to enable this warning, in -Wall or -Wextra, and, well maybe
> enable -Wcast-align=strict also at the same warning level, since it is
> currently
> not enabled at all, unless explicitly requested, what do you think?
Across Fedora there's only around a dozen packages that tripped over
this. That's a small enough set that I'm not terribly concerned about
the noise factor.
jeff