[Issue 3022] New: scope x = new Foo; does not allocate on stack if Foo has allocator
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat May 23 08:53:20 PDT 2009
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 at digitalmars.com
ReportedBy: leo.dahlmann at 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: -------
More information about the Digitalmars-d-bugs
mailing list