[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <549b61046b134234bd4bffd85315f29a@AcuMS.aculab.com>
Date: Tue, 14 Sep 2021 15:03:51 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Arnd Bergmann' <arnd@...nel.org>,
Guenter Roeck <linux@...ck-us.net>
CC: Sam Ravnborg <sam@...nborg.org>,
"David S . Miller" <davem@...emloft.net>,
"sparclinux@...r.kernel.org" <sparclinux@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] sparc: mdesc: Fix compile error seen with gcc 11.x
From: Arnd Bergmann
> Sent: 14 September 2021 15:54
>
> On Tue, Sep 14, 2021 at 4:24 PM Guenter Roeck <linux@...ck-us.net> wrote:
> > On 9/14/21 7:17 AM, David Laight wrote:
> > >> Sorry, I didn't realize that a field of size 0 increases the structure size
> > >> on sparc. I had checked the size of the old and the new structure with gcc
> > >> on x86_64 and didn't see a field size increase.
> > >
> > > clang output doesn't change:
> > >
> > > https://godbolt.org/z/bTeeq19j1
> > >
> > > gcc ought to generate the same size.
> > >
> > > It ought to be 'char data[];' though.
> > >
> >
> > I am never sure if [] or [0] is "correct". Anyway, is there agreement that this
> > is an acceptable solution ? I'll be happy to resend if that is the case.
>
> Yes, looks good to me, in the [] version. I think the [0] version can be
> interpreted as a zero-length array that may not be accessed, while the
> [] flexible array syntax clearly means that extra data follows, and it's
> part of the C standard now, while [0] is a gcc extension.
More problematic is where is the correct place for the 'char data[]'.
It follows the header rather than being part of it.
So the:
data = (void *)(hdr + 1);
construct (I've lost the original patch) is absolutely descriptive.
gcc is getting to be a real PITA for system coding.
For this particular check 'size 0' ought to be 'size unknown'
and always valid.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists