================
@@ -431,3 +431,43 @@ int g = sizeof(G);
// CHECK-NEXT: | nvsize=20, nvalign=2, preferrednvalign=2]
} // namespace test11
+namespace test12 {
+// Fields whose base element is `double`/`long double` test their natural
+// 8-byte alignment under __ms_struct__.
+// See: issue 219627.
+struct __attribute__((__ms_struct__)) S { double d; };
+int a = sizeof(S);
+
+struct __attribute__((__ms_struct__)) LD { long double d; };
+int b = sizeof(LD);
+
+struct __attribute__((__ms_struct__)) CD { _Complex double d; };
+int c = sizeof(CD);
+
+struct __attribute__((__ms_struct__)) Arr { double d[4]; };
+int e = sizeof(Arr);
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT: 0 | struct test12::S
+// CHECK-NEXT: 0 | double d
+// CHECK-NEXT: | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT: | nvsize=8, nvalign=8, preferrednvalign=8]
----------------
hubert-reinterpretcast wrote:
> The GCC documentation creates no impression that `-m[no-]ms-bitfields`
> modifies behaviour on the Power-versus-natural-alignment axis
Which is not to say that it doesn't have some effect that could be described as
such (or perhaps more generally in terms of required versus preferred
alignment).
Observe:
```console
$ ( set -x ; cat msstruct2.c && gcc -std=c2x -Wall -Wextra -pedantic
-fsyntax-only msstruct2.c && gcc -v )
+ cat msstruct2.c
typedef struct [[gnu::ms_struct]] A { char c; double d; } A;
static_assert(alignof(A) == 8);
static_assert(__builtin_offsetof(A, d) == 8);
+ gcc -std=c2x -Wall -Wextra -pedantic -fsyntax-only msstruct2.c
+ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/freeware/libexec/gcc/powerpc-ibm-aix7.2.0.0/13/lto-wrapper
Target: powerpc-ibm-aix7.2.0.0
Configured with: ../gcc-13.3.0/configure --prefix=/opt/freeware
--mandir=/opt/freeware/man --infodir=/opt/freeware/info
--with-local-prefix=/opt/freeware --enable-languages=c,c++,fortran,go
--enable-version-specific-runtime-libs --disable-nls --disable-libstdcxx-pch
--disable-werror --enable-libstdcxx-filesystem-ts --with-gcc-major-version-only
--program-suffix=-13 --with-cpu=default32 --host=powerpc-ibm-aix7.2.0.0
--with-libiconv-prefix=/opt/freeware/libiconv_static
--with-libiconv-type=static --with-included-gettext
Thread model: aix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (GCC)
```
https://github.com/llvm/llvm-project/pull/219661
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits