This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients methane, petr.viktorin, pitrou, vstinner
Date 2022-03-31.13:39:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
On my x86-64 Fedora 35, gcc says 32 bytes for sizeof(max_align_t). By the way, g++ also says 32 bytes for sizeof(std::max_align_t).

GCC 11.2.1 defines max_align_t as:
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \
  || (defined(__cplusplus) && __cplusplus >= 201103L)
#ifndef _GCC_MAX_ALIGN_T
#define _GCC_MAX_ALIGN_T
/* Type whose alignment is supported in every context and is at least
   as great as that of any standard type not using alignment
   specifiers.  */
typedef struct {
  long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
  long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
  /* _Float128 is defined as a basic type, so max_align_t must be
     sufficiently aligned for it.  This code must work in C++, so we
     use __float128 here; that is only available on some
     architectures, but only on i386 is extra alignment needed for
     __float128.  */
#ifdef __i386__
  __float128 __max_align_f128 __attribute__((__aligned__(__alignof(__float128))));
} max_align_t;
#endif /* C11 or C++11.  */
file: /usr/lib/gcc/x86_64-redhat-linux/11/include/stddef.h

It's not an union but a structure with 2 fields (1 long long, 1 long double). The __i386__ macro is not defined on Linux x86-64, so the struct does not have the 3rd 128-bit float field.

#include <stddef.h>
int main() { return sizeof(max_align_t); }

Build and run (C):
$ gcc align.c -o align && (./align; echo $?)

int main() { return sizeof(std::max_align_t); }

Build and run (C++):
$ g++ align.cpp -o align && (./align; echo $?)
Date User Action Args
2022-03-31 13:39:19vstinnersetrecipients: + vstinner, pitrou, petr.viktorin, methane
2022-03-31 13:39:19vstinnersetmessageid: <>
2022-03-31 13:39:19vstinnerlinkissue47179 messages
2022-03-31 13:39:19vstinnercreate