Bug 16226 – -dip25 doesn't work if the return type is not explicit
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-02T01:13:00Z
Last change time
2016-10-01T11:48:12Z
Keywords
safe
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2016-07-02T01:13:08Z
This code results in an error with -dip25:
void main() @safe
{
int i;
foo(i);
}
ref int foo(ref int bar) @safe
{
return bar;
}
but this code
void main() @safe
{
int i;
foo(i);
}
ref foo(ref int bar) @safe
{
return bar;
}
and this code
void main() @safe
{
int i;
foo(i);
}
ref auto foo(ref int bar) @safe
{
return bar;
}
do not result in an error. Note that unless the return type actually includes int explictly rather than letting it be inferred, -dip25 is bypassed completely. Interestingly enough, it does catch this case though and error out correctly:
void main() @safe
{
foo();
}
ref foo() @safe
{
int bar = 42;
return bar;
}