bug-gnulib
[Top][All Lists]
Advanced

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

Re: alignof failure


From: Bruno Haible
Subject: Re: alignof failure
Date: Thu, 14 May 2009 09:36:29 +0200
User-agent: KMail/1.9.9

Simon Josefsson wrote:
> The alignof module seems to have problems:
> 
> address@hidden:~/src/gnulib master$ gnulib-tool --test --with-tests alignof
> ...
> ../../gltests/test-alignof.c:41: error: negative width in bit-field 
> ‘verify_error_if_negative_size__’

I reproduce with all versions of gcc since 3.1, on x86, when -malign-double
is not specified.

  offsetof (struct { char slot1; double slot2; }, slot2)
is 4 by default, but 8 when -malign-double is specified.

Whereas
  __alignof__ (double)
is always 8 on x86; this is even part of the GCC test suite [1].

[2] says: "It turns out that the alignment of a type can differ from the
  alignment of a field of that type. In particular, on x86 alignof(double)
  is 8, but a double as a field has alignment 4."

I'm not sure which one we should use in gnulib. Probably the "alignment of a
field of that type" semantics, because that's what we use alignof for?

Bruno


[1] 
https://www.codeblog.org/viewsrc/gcc-4.1.0/gcc/testsuite/g++.old-deja/g++.abi/align.C
[2] http://gcc.gnu.org/ml/java-patches/2003-q2/msg00098.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]