[Issue 14103] New: dmd doesn't treat opIn as unsafe
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Feb 1 09:58:49 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14103
Issue ID: 14103
Summary: dmd doesn't treat opIn as unsafe
Product: D
Version: unspecified
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
cat > bug.d << CODE
int foo(int[int] aa) @safe
{
auto p = 12 in aa;
aa.remove(12);
return *p;
}
CODE
dmd -c bug
----
Here p is a pointer to the value stored in the AA.
Used for anything else but a boolean comparison, `in` is an unsafe operation.
----
cat > bug.d << CODE
int foo(int[] aa) @safe
{
auto p = &aa[12];
aa.length = 10;
return *p;
}
CODE
dmd -c bug
----
Ironically the similar operation on an array isn't treated as unsafe either.
--
More information about the Digitalmars-d-bugs
mailing list