[Issue 22624] New: importC: bit field misaligns following members in D struct .init
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 23 01:17:13 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22624
Issue ID: 22624
Summary: importC: bit field misaligns following members in D
struct .init
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: duser at airmail.cc
mod.c:
---
struct cstruct {
unsigned int bit : 1;
};
---
main.d:
---
import std.stdio;
import mod;
struct dstruct
{
cstruct x;
ubyte[8] msg = [1, 2, 3, 4, 5, 6, 7, 8];
}
void main()
{
dstruct v;
writeln(v.msg);
assert(dstruct.init.msg == [1, 2, 3, 4, 5, 6, 7, 8]); // ok
assert(v.msg == [1, 2, 3, 4, 5, 6, 7, 8]); // error
}
---
it should print the array as written in the source, but instead it prints [0,
0, 0, 0, 1, 2, 3, 4]
version: DMD64 D Compiler v2.098.0-361-g415e58e6d (current git master)
--
More information about the Digitalmars-d-bugs
mailing list