[Issue 18484] New: [dip1000] Subtype allows reference to escape with implicit casting
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 21 15:37:34 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18484
Issue ID: 18484
Summary: [dip1000] Subtype allows reference to escape with
implicit casting
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: radu.racariu at gmail.com
Compile the following with dmd 2.079-beta1 (older compilers behave the same)
and -dip1000:
================================
struct S
{
@property char[] c() return
{
return i.c;
}
alias c this;
static struct I
{
char[] c;
}
I* i;
}
char[] c()
{
auto x = S();
return x;
}
===========================
Produces a nice error:
Error: returning x.c() escapes a reference to local variable x
Now change 'c' function to this
===========================
char[] c()
{
return S();
}
===========================
No error is reported.
Expected to see the same error.
--
More information about the Digitalmars-d-bugs
mailing list