Bug 14486 – delete on classes ignores @nogc

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-24T05:17:00Z
Last change time
2016-02-01T10:30:47Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
ketmar

Comments

Comment #0 by ketmar — 2015-04-24T05:17:30Z
the following code gives error: "cannot use 'delete' in @nogc function main" class Foo { @nogc this () {} @trusted nothrow @nogc new (size_t size) { import core.stdc.stdlib : malloc; auto res = malloc(size); if (res is null) { import core.exception : onOutOfMemoryError; onOutOfMemoryError(); } return res; } nothrow @nogc delete (void* p) { import core.stdc.stdlib : free; free(p); } } void main () @nogc { auto f = new Foo(); delete f; } compiler doesn't check if class has overload `delete` marked as `@nogc`.
Comment #1 by k.hara.pg — 2015-08-04T23:09:34Z
Comment #2 by github-bugzilla — 2016-02-01T10:30:47Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2c6618d3015d9ea1969a298d1da3293fa18a48b9 fix Issue 14486 - delete on classes ignores @nogc Also check other attributes, pure @safe and nothrow in DeleteExp https://github.com/D-Programming-Language/dmd/commit/5665dc7aadc241996d6f405866b1c3735c39c403 Merge pull request #4860 from 9rnsr/fix14486 Issue 14486 - delete on classes ignores @nogc