Bug 10521 – Struct wrong constructor chosen.

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-01T09:44:00Z
Last change time
2015-06-09T05:11:39Z
Assigned to
nobody
Creator
damianday

Comments

Comment #0 by damianday — 2013-07-01T09:44:59Z
// Test case, worked fine in 2.062 struct Test { enum DefaultSize = 256; int size; this(int sz = DefaultSize ) { size = sz; } } void main() { Test st_test; assert(st_test.size == Test.DefaultSize); // Wrong constructor chosen! }
Comment #1 by damianday — 2013-07-01T10:16:46Z
This is a correct test case, ignore the previous one. Anyway tested now with Git Head and the issue has been resolved! Hooray :) struct Test { enum DefaultSize = 256; int size; this(int sz = DefaultSize ) { size = sz; } ~this() { assert(size == DefaultSize); } } public class ClassA { private Test st_test; public this() { st_test = Test(256); } } void main() { auto cl = new ClassA; }