Bug 3022 – scope x = new Foo; does not allocate on stack if Foo has allocator

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-05-23T08:53:00Z
Last change time
2015-02-18T03:36:36Z
Keywords
patch, pull, wrong-code
Assigned to
yebblies
Creator
leo.dahlmann

Attachments

IDFilenameSummaryContent-TypeSize
379scope-new-fix.patchPatch to fix bugtext/plain593

Comments

Comment #0 by leo.dahlmann — 2009-05-23T08:53:19Z
Created attachment 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.
Comment #1 by k.hara.pg — 2014-05-28T02:26:24Z
Comment #2 by yebblies — 2014-09-09T14:40:37Z
Comment #3 by github-bugzilla — 2014-09-10T09:33:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e7242b67874b5b9ac4c416d76a54ee7b037108be Fix Issue 3022 - scope x = new Foo; does not allocate on stack if Foo has allocator If new only has one argument, then it must be the size. https://github.com/D-Programming-Language/dmd/commit/9ba3bf09acb5d0133998781c506347f482497c0c Merge pull request #3968 from yebblies/issue3022 Issue 3022 - scope x = new Foo; does not allocate on stack if Foo has allocator
Comment #4 by github-bugzilla — 2015-02-18T03:36:36Z
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e7242b67874b5b9ac4c416d76a54ee7b037108be Fix Issue 3022 - scope x = new Foo; does not allocate on stack if Foo has allocator https://github.com/D-Programming-Language/dmd/commit/9ba3bf09acb5d0133998781c506347f482497c0c Merge pull request #3968 from yebblies/issue3022