Bug 1088 – structs allocated with a struct allocator will not have default initializer values assigned

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2007-03-31T19:20:00Z
Last change time
2013-01-08T15:40:23Z
Keywords
wrong-code
Assigned to
nobody
Creator
guido

Comments

Comment #0 by guido — 2007-03-31T19:20:55Z
/* * dmd -w -O dtest.d * ./dtest * static_foo.a = 800 * dynamic_foo.a = 100 */ import std.stdio; int storage = 100; struct foo { new(uint size, void* p) { return p; } int a = 800; } void main() { foo static_foo; writefln("static_foo.a = %d", static_foo.a); foo* dynamic_foo = new(&storage) foo; writefln("dynamic_foo.a = %d", dynamic_foo.a); }
Comment #1 by thomas-dloop — 2007-04-04T15:36:11Z
Comment #2 by andrei — 2011-01-08T13:03:56Z
D1 only - D2 will eliminate custom operator new.
Comment #3 by yebblies — 2012-02-15T22:32:17Z
These all seem to work, in D1 and D2 (1.072, 2.058)
Comment #4 by andrej.mitrovich — 2013-01-08T15:40:23Z
(In reply to comment #2) > D2 will eliminate custom operator new. If this is going to happen we should implement a deprecation stage (initially add a note to the docs, then the compiler can eventually emit a warning, and later reject such code). We've lost 2 years which could have been used to deprecate the feature.