lkml.org 
[lkml]   [2022]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] x86/fpu: use __alignof__ to avoid UB in TYPE_ALIGN
Date
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)
\
 
 \ /
  Last update: 2022-09-27 10:22    [W:0.074 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site