Bug 4749 – Templated & non-templated constructors conflicting

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-28T21:52:00Z
Last change time
2013-07-20T21:58:59Z
Assigned to
nobody
Creator
mitch.hayenga

Comments

Comment #0 by mitch.hayenga — 2010-08-28T21:52:39Z
I don't have a D compiler on me at the moment, but this came up earlier today. Heres a simplified case. // This breaks due to the constructors (template error message from DMD) struct A { Variant v; string s; this(T)(T val, string str) { v = Variant(val); str = s; } this(int val) { v = val; } } // This works struct A { Variant v; string s; this(T)(T val, string str) { v = Variant(val); str = s; } this(T)(int val) { // Useless template parameter v = val; } }
Comment #1 by mitch.hayenga — 2010-08-28T21:59:26Z
Btw, oops bugs in that code. Swapped s & str in the assignment.
Comment #2 by mitch.hayenga — 2010-08-28T22:08:43Z
Also likely the same bug as 2972.
Comment #3 by braddr — 2011-02-06T15:40:09Z
Mass migration of bugs marked as x86-64 to just x86. The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment #4 by simendsjo — 2011-08-02T06:46:56Z
A smaller test case: struct S { this()(int v) {} this(char[] v) {} } t.d(3): Error: constructor t.S.this conflicts with template t.S.__ctor() at t.d( 2)
Comment #5 by issues.dlang — 2013-07-20T21:58:59Z
*** This issue has been marked as a duplicate of issue 1528 ***