D - posible bug: new/delete
- Carlos Santander B. (31/31) Sep 08 2003 I tried the example from memory.html:
I tried the example from memory.html:
import c.stdio, c.stdlib, gc, outofmemory;
void main() {
Foo foo=new Foo;
//delete foo;
}
class Foo {
new(uint sz) {
void* p;
p = c.stdlib.malloc(sz);
if (!p)
throw new OutOfMemory();
gc.addRange(p, p + sz);
return p;
}
delete(void* p) {
if (p) {
gc.removeRange(p);
c.stdlib.free(p);
}
printf("~Foo"); //added this
}
}
with the stated change. However, It never prints "~Foo". And if I uncomment
"delete foo" I get "Error: Win32 Exception". Now, I've never done anything
with allocators, etc., but I just think this isn't right, is it?
-------------------------
Carlos Santander
---
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 2003-09-01
Sep 08 2003








"Carlos Santander B." <carlos8294 msn.com>