Issue 131647
Summary [clang] -Wpadded-bitfield warns a wrong number of padded bytes with ms_struct
Labels
Assignees
Reporter therealcoochieman
    For the following struct:
```c
struct __attribute__((ms_struct)) Foo {
  long long x;
  char a : 1;
  long long b : 1;
};
```

We should have a padding of 63 bits between `a` and `b` as the compiler aims for an 8 byte alignment, with `a` taking 1 bit and `b` having a different underlying type.

The following command `clang -Wpaded foo.cc` gives out the following warning:
```
test.cc:4:13: warning: padding struct 'Foo' with 7 bytes to align 'yy' [-Wpadded-bitfield]
    4 |   long long yy : 1;
      | ^
test.cc:1:35: warning: padding size of 'Foo' with 63 bits to alignment boundary [-Wpadded]
    1 | struct __attribute__((ms_struct)) Foo {
      | ^
```

>From my understanding, something is wrong with the way the alignment warning for `-Wpadded-bitfield` is computed. Can somebody confirm this?

If confirmed, I would like to work on this issue.
 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to