www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20604] New: [ICE] dtoh ICE with nested template structs (and

https://issues.dlang.org/show_bug.cgi?id=20604

          Issue ID: 20604
           Summary: [ICE] dtoh ICE with nested template structs (and
                    probably most templates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: C++, ice, ice-on-valid-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

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]
```

--
Feb 24 2020