[Issue 21212] New: [DIP1000] taking `ref` parameter address check leaking when dip1000 is enabled
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 31 06:58:36 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21212
Issue ID: 21212
Summary: [DIP1000] taking `ref` parameter address check leaking
when dip1000 is enabled
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: outland.karasu at gmail.com
When enabled DIP1000, DMD(v2.093.1) allow taking `ref` parameter address.
But it should be compile error as disabled DIP1000.
reduced code by ag0aep6g
https://forum.dlang.org/post/rii2s5$2ms5$1@digitalmars.com
----
class MinPointerRecorder
{
int* minPrice;
void update(ref int price) @safe
{
minPrice = &price; /* Should not compile. */
}
}
void main() @safe
{
auto r = new MinPointerRecorder;
() { int mp = 42; r.update(mp); } ();
() { ulong[1000] stomp = 13; } ();
import std.stdio: writeln;
writeln(*r.minPrice); /* Prints "13". */
}
----
rdmd result
(v2.093.1 Darwin Kernel Version 19.6.0 x86_64)
----
% dmd --version
DMD64 D Compiler v2.093.1
% rdmd -preview=dip1000 issue.d
13
% rdmd issue.d
issue.d(6): Error: cannot take address of parameter price in @safe function
update
----
--
More information about the Digitalmars-d-bugs
mailing list