Re: [PATCH] [RFC v2] qnx: avoid -Wstringop-overread warning, again

From: Arnd Bergmann
Date: Tue Sep 21 2021 - 04:19:19 EST


On Mon, Sep 20, 2021 at 7:26 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Mon, Sep 20, 2021 at 5:12 AM Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
> >
> > + /*
> > + * work around gcc-11.x using the first field it observes
> > + * to determing the actual length
> > + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
> > + */
> > + char __empty[0];
> > + char de_name[];
>
> Ugh. That looks _really_ hacky.
>
> It sounds like we can avoid the gcc bug if we just always use
> "de->de_name[]". Then we don't need to depend on magical behavior
> about one particular gcc version and a strange empty array in front of
> it.
>
> IOW, something like the attached simpler thing that just does that
> "always use de_name[]" and has a comment about why we don't do the
> natural thing

Yes, your patch is much nicer than my attempt. I checked it overnight
and it addresses all the randconfig issues I found.

> Also, just what version of gcc is the broken one? You say "gcc-11",
> but I certainly don't see it with _my_ version of gcc-11, so can we
> (just for that comment) document more precisely what version you have
> (or possibly what config you use to trigger it).

I'm using the gcc-11.1.0 that I uploaded to
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/

The gcc bug is still open and currently targets gcc-11.3. To make it
worse, this is definitely configuration dependent, and I do not see it
in an allmodconfig build, but only certain randconfig builds. I originally
had a simpler patch myself and also found that this did not fully
address all kernel configs.
gcc-10.x and early do not show the problem, I think the warning
was only introduced in 11.1.

https://pastebin.com/raw/fXmNiute is a .config for x86 that showed the
problem for me on 5.15-rc2 but not with your new patch.

Arnd