NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: standards/52571: max_align_t has smaller alignment than double



On Mon, Sep 25, 2017 at 04:55:00PM +0000, bruno%clisp.org@localhost wrote:
> max_align_t is supposed to have the largest alignment among the
> standard C types. But here, __alignof__(max_align_t) < __alignof__(double).

So this one is a nice excercise in GCC extensions and why they sometimes
don't give you what you think they do. Compare the following test case
on i386 with and without USE_ALIGNOF:

#include <stddef.h>

struct foo {
  double x;
  char t;
};

int main() {
#ifdef USE_ALIGNOF
  return __alignof__(double);
#else
  return sizeof(struct foo) - offsetof(struct foo, t);
#endif
}

---

For the SYSV ABI (not the bastardized version Linux is nowadays using),
the ABI alignment of double is 32bit, but most compiler use a prefered
alignment of 64bit. Similar for long double.

Joerg


Home | Main Index | Thread Index | Old Index