digitalmars.D.bugs - [Issue 14103] New: dmd doesn't treat opIn as unsafe
- via Digitalmars-d-bugs (38/38) Feb 01 2015 https://issues.dlang.org/show_bug.cgi?id=14103
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 puremagic.com Reporter: code 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. --
Feb 01 2015