Bug 20604 – [ICE] dtoh ICE with nested template structs (and probably most templates

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-24T12:28:55Z
Last change time
2020-10-16T23:32:37Z
Keywords
C++, ice, ice-on-valid-code, pull
Assigned to
No Owner
Creator
Mathias LANG

Comments

Comment #0 by pro.mathias.lang — 2020-02-24T12:28:55Z
dtoh currently doesn't seem to have much handling of templates. It ignore trivial cases of templated functions, but nesting defeats it quite easily and triggers an ICE: ``` extern(C++) { struct Foo (T) { T val; } struct Bar (T) { Foo!T v; } } ``` Triggers: ``` ./generated/osx/release/64/dmd -HC -c foo.d Invalid type: Foo!T --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.090.1-244-gca55eb392 predefs DigitalMars Posix OSX CppRuntime_Clang darwin LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat D_ObjectiveC binary ./generated/osx/release/64/dmd version v2.090.1-244-gca55eb392 config ./generated/osx/release/64/dmd.conf DFLAGS -I./generated/osx/release/64/../../../../../druntime/import -I./generated/osx/release/64/../../../../../phobos -L-L./generated/osx/release/64/../../../../../phobos/generated/osx/release/64 -fPIC --- core.exception.AssertError@dmd/dtoh.d(1096): Assertion failure ---------------- ??:? _d_assertp [0x1081a1bd5] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP4Type [0x107f7737c] dmd/access.d:393 _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP13TypeQualified [0x108055c26] dmd/access.d:393 _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP12TypeInstance [0x108055e59] dmd/access.d:393 _ZN12TypeInstance6acceptEP7Visitor [0x108025f41] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE12typeToBufferEP4TypeP10Identifier [0x107f77280] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP14VarDeclaration [0x107f75877] dmd/access.d:393 _ZN14VarDeclaration6acceptEP7Visitor [0x107f0b7f1] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP19TemplateDeclaration [0x107f7829e] dmd/access.d:393 _ZN19TemplateDeclaration6acceptEP7Visitor [0x107f65c59] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP17AttribDeclaration [0x107f74d43] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP15LinkDeclaration [0x107f74dcf] dmd/access.d:393 _ZN15LinkDeclaration6acceptEP7Visitor [0x107ed4d19] dmd/access.d:393 _ZN11ToCppBufferI10ASTCodegenE5visitEP6Module [0x107f74e5f] dmd/access.d:393 _ZN6Module6acceptEP7Visitor [0x107f2d9a9] dmd/access.d:393 _Z14genCppHdrFilesR5ArrayIP6ModuleE [0x107f7498a] dmd/access.d:393 int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x108013802] dmd/access.d:393 _Dmain [0x1080147cf] ```
Comment #1 by dlang-bot — 2020-10-16T22:06:44Z
@MoonlightSentinel created dlang/dmd pull request #11875 "Fix 20604 - [ICE] dtoh ICE with nested template structs" fixing this issue: - Fix 20604 - [ICE] dtoh ICE with nested template structs Define a handler for TypeInstance and handle potentially missing template identifiers https://github.com/dlang/dmd/pull/11875
Comment #2 by dlang-bot — 2020-10-16T23:32:37Z
dlang/dmd pull request #11875 "Fix 20604 - [ICE] dtoh ICE with nested template structs" was merged into master: - bf4d9dc5b4c13dfc5e8c98b065af8a12956c2876 by MoonlightSentinel: Fix 20604 - [ICE] dtoh ICE with nested template structs Define a handler for TypeInstance and handle potentially missing template identifiers https://github.com/dlang/dmd/pull/11875