May 23, 2009 [Issue 3022] New: scope x = new Foo; does not allocate on stack if Foo has allocator | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3022 Summary: scope x = new Foo; does not allocate on stack if Foo has allocator Product: D Version: 1.044 Platform: PC OS/Version: All Status: NEW Keywords: patch, wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: leo.dahlmann@gmail.com Created an attachment (id=379) --> (http://d.puremagic.com/issues/attachment.cgi?id=379) Patch to fix bug extern(C) int printf(char*, ...); class Foo { new(size_t) { printf("Foo.new\n"); return null; } } void main() { scope x = new Foo; } Outputs "Foo.new" at runtime, even though the spec says that objects having custom allocators will be allocated on the stack if they are called without arguments to new. This seems to be caused by dmd automatically prepending the class size to new's arguments list, so it always has at least one argument. Attached is a patch to fix this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation