[Issue 19916] New: union member access should be un- at safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 28 22:24:20 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19916
Issue ID: 19916
Summary: union member access should be un- at safe
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
It should be invalid to access members of unions in @safe code.
It is necessary that code that interacts with unions implements the runtime
checks in a @trusted function.
struct S
{
union
{
int x;
float y;
}
bool whichOne;
}
void fun() @safe
{
S s;
int t = s.x; // COMPILE ERROR: NOT SAFE
s.x = 10; // COMPILE ERROR: NOT SAFE
}
--
More information about the Digitalmars-d-bugs
mailing list