Bug 9273 – DMD segfaults with templated ctors in implicit super call

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-05T07:27:00Z
Last change time
2013-01-09T03:40:19Z
Keywords
ice, pull
Assigned to
nobody
Creator
admin

Comments

Comment #0 by admin — 2013-01-05T07:27:19Z
class NBTFile : TAG_Compound { } template _Base_TAG(int id_, DType_) { this(T)() { } } class TAG { } class TAG_Compound { mixin _Base_TAG!(10, TAG); } This segfaults dmd, it's a dustmite reduction the whole code compiled under 2.060 so I guess it's a regression.
Comment #1 by admin — 2013-01-05T07:33:08Z
To make it even better: Compiles: --------------------------------------- class NBTFile : TAG_Compound { this()() {} } template _Base_TAG(int id_, DType_) { this(T)() { } } struct TAG {} class TAG_Compound { mixin _Base_TAG!(10, TAG); } --------------------------------------- Fails: --------------------------------------- class NBTFile : TAG_Compound { this()() {} } template _Base_TAG(int id_, DType_) { this(T)() { } } struct TAG {} class TAG_Compound { mixin _Base_TAG!(10, TAG); } void main() { NBTFile s = new NBTFile(); } ---------------------------------------
Comment #2 by k.hara.pg — 2013-01-08T23:18:23Z
A simplified test case: --- template CtorMixin() { this(T)() {} } class B { mixin CtorMixin!(); } class C : B { this()() {} } void main() { auto c = new C(); } --- (In reply to comment #0) > This segfaults dmd, it's a dustmite reduction the whole code compiled under > 2.060 so I guess it's a regression. I think it is an accepts-invalid code in 2.060 and earlier. In class NBTFile, implicitly generated default constructor will try to call super class default constructor. But, in its super class TAG_Compound, template constructor - which mixed in by _Base_TAG - requires explicit template parameter to call. Therefore, the generating an implicit constructor in NBTFile and whole compilation should fail.
Comment #3 by k.hara.pg — 2013-01-08T23:23:59Z
*** Issue 8768 has been marked as a duplicate of this issue. ***
Comment #4 by k.hara.pg — 2013-01-08T23:25:22Z
Most simple test case from bug 8768. --- class A { this(T)() {} } class B : A { this() {} } ---- B.this() cannot call A.this(T)() implicitly.
Comment #5 by k.hara.pg — 2013-01-08T23:54:39Z
Comment #6 by k.hara.pg — 2013-01-09T03:39:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1c8305dbf70dafb1528b73c317108fb2901eb604 fix Issue 9284 - DMD segfaults with templated ctors in constructor delegation https://github.com/D-Programming-Language/dmd/commit/a899e6147517f78f6d23064ca764533b789b8579 Merge pull request #1451 from 9rnsr/fix9273 Issue 9273 & 9284 - DMD segfaults with templated ctors