[llvm-bugs] [Bug 25707] New: [GCC compatibility] different layout for ms_struct with bit-field

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 2 05:01:25 PST 2015


            Bug ID: 25707
           Summary: [GCC compatibility] different layout for ms_struct
                    with bit-field
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dmitry.polukhin at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ cat test3.c
#include <stddef.h>
#include <stdio.h>

struct __attribute__((ms_struct)) B {
  char AField;
  int b : 1;
  char BField;

int main() {
  printf("sizeof(struct B) = %ld\n", sizeof(struct B));
  printf("offsetof(struct B, BField) = %ld\n", offsetof(struct B, BField));
  printf("__alignof(struct B) = %ld\n", __alignof(struct B));

$ clang test3.c && ./a.out
sizeof(struct B) = 12
offsetof(struct B, BField) = 8
__alignof(struct B) = 4

$ gcc test3.c && ./a.out
sizeof(struct B) = 8
offsetof(struct B, BField) = 5
__alignof(struct B) = 4

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151202/57bf8966/attachment.html>

More information about the llvm-bugs mailing list