[Issue 21380] New: compiler crashes when using auto ref

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 12 09:56:24 UTC 2020


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

          Issue ID: 21380
           Summary: compiler crashes when using auto ref
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: feco.graczer at gmail.com

struct MySerializer (T)
{
        void serializeSinkType(T2) (scope auto ref T2 record) {}
}

template SupportSinkTypeSer(SerT)
{
        enum SupportSinkTypeSer =
isSomeFunction!(SerT.init.serializeSinkType!int);
}

int main()
{
        enum x = SupportSinkTypeSer!(MySerializer!int);
        return 0;
}

crashes compiler DMD64 D Compiler v2.094.0

with

 #0 0x00007f28935b94ff llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x9814ff)
 #1 0x00007f28935b7782 llvm::sys::RunSignalHandlers()
(/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x97f782)
 #2 0x00007f28935b9ac5 (/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x981ac5)
 #3 0x00007f28926d73c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #4 0x000056251ebb125f
_D3dmd10dinterpret13ctfeInterpretFCQBh10expression10ExpressionZQBd
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x3c425f)
 #5 0x000056251ea5b7ef
_D3dmd9dtemplate16TemplateInstance14semanticTiargsFKxSQCa7globals3LocPSQCr6dscope5ScopePSQDj4root5array__T5ArrayTCQEiQz10rootobject10RootObjectZQBmiZb
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x26e7ef)
 #6 0x000056251eb81406 ExpressionSemanticVisitor::visit(ScopeExp*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x394406)
 #7 0x000056251eb3fa80
_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZ8visitExpMFCQCxQCa14ExpInitializerZQCx
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x352a80)
 #8 0x000056251eb3f655
_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZQBo
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x352655)
 #9 0x000056251ebe1061 DsymbolSemanticVisitor::visit(VarDeclaration*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x3f4061)
#10 0x000056251ebdb132
_D3dmd9dtemplate16TemplateInstance13expandMembersMFPSQBz6dscope5ScopeZv
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x3ee132)
#11 0x000056251ebd1ec9
_D3dmd10dsymbolsem24templateInstanceSemanticFCQBs9dtemplate16TemplateInstancePSQCz6dscope5ScopePSQDr4root5array__T5ArrayTCQEq10expression10ExpressionZQBkZv
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x3e4ec9)
#12 0x000056251eb8146a ExpressionSemanticVisitor::visit(ScopeExp*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x39446a)
#13 0x000056251eb3fa80
_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZ8visitExpMFCQCxQCa14ExpInitializerZQCx
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x352a80)
#14 0x000056251eb3f655
_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZQBo
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x352655)
#15 0x000056251ebe1061 DsymbolSemanticVisitor::visit(VarDeclaration*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x3f4061)
#16 0x000056251eb8bd42 ExpressionSemanticVisitor::visit(DeclarationExp*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x39ed42)
#17 0x000056251ea668df StatementSemanticVisitor::visit(ExpStatement*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x2798df)
#18 0x000056251ea6729a StatementSemanticVisitor::visit(CompoundStatement*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x27a29a)
#19 0x000056251ea96f3a Semantic3Visitor::visit(FuncDeclaration*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x2a9f3a)
#20 0x000056251ea952cf Semantic3Visitor::visit(Module*)
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x2a82cf)
#21 0x000056251eb0c3fc mars_mainBody(Param&, Array<char const*>&, Array<char
const*>&) (/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x31f3fc)
#22 0x000056251ed4f1f2 cppmain()
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x5621f2)
#23 0x00007f289279f9dc _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv
(/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so.90+0xba9dc)
#24 0x00007f289279f7ef _d_run_main2
(/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so.90+0xba7ef)
#25 0x00007f289279f65e _d_run_main
(/lib/x86_64-linux-gnu/libdruntime-ldc-shared.so.90+0xba65e)
#26 0x000056251ea28535 main
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x23b535)
#27 0x00007f28921aa0b3 __libc_start_main
/build/glibc-YYA7BZ/glibc-2.31/csu/../csu/libc-start.c:342:3
#28 0x000056251ea2aabe _start
(/home/dan/dev/thirdparty/install-ldc-latest/bin/ldc2+0x23dabe)
Segmentation fault (core dumped)
ldc2 failed with exit code 139.

workaround is to remove the auto keyword, in that case it compiles...

--


More information about the Digitalmars-d-bugs mailing list