[Issue 22045] New: Assignment of pointers in union should be @safe, only pointers access are @system
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jun 19 17:18:56 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22045
Issue ID: 22045
Summary: Assignment of pointers in union should be @safe, only
pointers access are @system
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: lsferreira169 at gmail.com
This code should successfully compile:
void main() @safe
{
union Foo {
int a;
int* b;
}
Foo foo;
foo.b = new int;
}
Nothing unsafe here.
It worked in DMD 2.065.0 to 2.071.2.
More examples:
void main() @safe
{
union Foo {
int a;
int* b;
}
Foo foo;
int* c = (foo.b = new int);
}
This, however shouldn't compile:
void main() @safe
{
union Foo {
int a;
int* b;
}
Foo foo;
int* c = foo.b;
}
--
More information about the Digitalmars-d-bugs
mailing list