Bug 11448 – `dup` calls @system impure code from @safe pure function

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-05T22:56:00Z
Last change time
2014-05-25T21:53:26Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
verylonglogin.reg
See also
https://d.puremagic.com/issues/show_bug.cgi?id=6646

Comments

Comment #0 by verylonglogin.reg — 2013-11-05T22:56:19Z
As `dup` calls postblit it should be either @system impure or conditionally @safe pure as suggested in Issue 5700: --- struct S { this(this){} } void main() @safe pure { S[1] s; s.dup; // should not be allowed } ---
Comment #1 by k.hara.pg — 2014-05-25T21:53:26Z
The issues is fixed in git-head (2.066a), by implementing 'dup' function in druntime. test.d(7): Error: pure function 'D main' cannot call impure function 'object.dup!(S).dup' test.d(7): Error: safe function 'D main' cannot call system function 'object.dup!(S).dup'