[Issue 14486] New: delete on classes ignores @nogc
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Apr 23 22:17:30 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14486
Issue ID: 14486
Summary: delete on classes ignores @nogc
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: ketmar at ketmar.no-ip.org
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`.
--
More information about the Digitalmars-d-bugs
mailing list