[Issue 22309] New: Taking the address of a stack variable struct with this is wrongly seen as @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 15 11:24:10 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22309
Issue ID: 22309
Summary: Taking the address of a stack variable struct with
this is wrongly seen as @safe
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: jlourenco5691 at gmail.com
struct Foo
{
Bar bar() @safe { return Bar(&this); }
}
struct Bar
{
this(Foo* foo) @safe {}
}
Bar unsafeUnderSafe() @safe
{
Foo foo;
return foo.bar;
}
Bar unsafe() @safe
{
Foo foo;
return Bar(&foo);
}
void main() @safe
{
auto b1 = unsafeUnderSafe();
auto b2 = unsafe();
}
--
More information about the Digitalmars-d-bugs
mailing list