This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Clarification required about bitfields


On December 23, 2015 9:28:32 AM GMT+01:00, Konstantin Vladimirov <konstantin.vladimirov@gmail.com> wrote:
>Hi,
>
>Now LLVM and GCC essentially disagrees on simple test (minimized from
>one of dejagnu tests):
>
>#include <stdlib.h>
>
>struct s {
>  unsigned long long u33: 33;
>  unsigned long long u40: 40;
>  unsigned long long u41: 41;
>};
>
>struct s a = { 0x100000, 0x100000, 0x100000 };
>
>int
>main (void)
>{
>  if (a.u33 * a.u33 != 0)
>    abort();
>
>  exit (0);
>}
>
>Compiled on GCC 5.2 passes, compiled on Clang 3.7 aborts. But when I
>filed bug https://llvm.org/bugs/show_bug.cgi?id=25852 against clang on
>this, it was resolved as invalid with comment that GCC behaves
>incorrect here.
>
>How do you think: who is right and should I file this bug in gcc
>bugzilla now?

GCCs reasoning is that types bigger than long do not promote thus the compute happens in a trivially 33bit type.

Richard.

>---
>With best regards, Konstantin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]