[Issue 22126] New: -checkaction=context should not print overlapped struct members
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 16 19:22:00 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22126
Issue ID: 22126
Summary: -checkaction=context should not print overlapped
struct members
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
Reduced test case:
```
struct S
{
union
{
double num;
immutable(char)[] name;
}
}
void main()
{
assert(S.init != S.init);
}
```
Compiling with -checkaction=context gives:
core.exception.OutOfMemoryError at src/core/exception.d(647): Memory allocation
failed
----------------
The problem is that the double 'num' overlaps the length field of 'name', and
double.nan interpreted as a length is 0x7FF8000000000000, so it's no wonder
Memory allocation failed.
formatMembers in core/internal/dassert.d should not naively iterate over
.tupleof but watch for overlapped fields.
--
More information about the Digitalmars-d-bugs
mailing list