[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <40fca2eef36a40f4b9a4145a0f7fe57c@AcuMS.aculab.com>
Date: Tue, 27 Sep 2022 08:20:39 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'YingChi Long' <me@...lyc.cn>,
Peter Zijlstra <peterz@...radead.org>
CC: "tglx@...utronix.de" <tglx@...utronix.de>,
"ndesaulniers@...gle.com" <ndesaulniers@...gle.com>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"x86@...nel.org" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
Paolo Bonzini <pbonzini@...hat.com>,
"Chang S. Bae" <chang.seok.bae@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] x86/fpu: use __alignof__ to avoid UB in TYPE_ALIGN
From: YingChi Long
> Sent: 26 September 2022 14:18
>
> Seems GCC __alignof__ is not evaluated to the minimum alignment of some
> TYPE, and depends on fields of the struct.
>
> > Notably I think 'long long' has 4 byte alignment on i386 and some other
> > 32bit archs.
>
> C11 _Alignof matches in the case (see godbolt link below). How about
> switch to _Alignof?
__alignof__() returns the preferred alignment, not the minimal one.
So one i386 it returns 8 for 'long long' rather than 4.
Using alignof(struct{long long x;}) does give the required 4.
(as does _Alignof()).
See https://godbolt.org/z/13xTYYd11
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists