[Issue 22955] New: importC: wrong alignof for D struct with specified alignment
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 29 15:18:14 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22955
Issue ID: 22955
Summary: importC: wrong alignof for D struct with specified
alignment
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: duser at neet.fi
CC: duser at neet.fi
using the "align (16) struct __uint128_t" struct from __builtins.di:
_Static_assert( _Alignof(__uint128_t) == 16, "" ); // fail
it gives the size of a pointer (4 or 8), same as if align() wasn't used
it has the correct alignment in D:
import __builtins;
pragma(msg, __uint128_t.alignof); // 16
_Alignas() in C doesn't have the problem:
struct S { _Alignas(16) unsigned long long a; unsigned long long b; };
_Static_assert( _Alignof(struct S) == 16, "this works" );
_Static_assert( sizeof(struct S) == 16, "this works" );
--
More information about the Digitalmars-d-bugs
mailing list