Bug 21380 – A case of compiler crash when using auto ref

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-12T09:56:24Z
Last change time
2021-11-08T20:45:40Z
Keywords
ice, pull
Assigned to
No Owner
Creator
Daniel

Comments

Comment #0 by feco.graczer — 2020-11-12T09:56:24Z
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...
Comment #1 by b2.temp — 2020-11-12T10:22:20Z
regression from 2.073.2 (https://run.dlang.io/is/9fOvpM) w/o phobos: --- template isSomeFunction(T...) if (T.length == 1) { static if (is(typeof(& T[0]) U : U*) && is(U == function) || is(typeof(& T[0]) U == delegate)) { // T is a (nested) function symbol. enum bool isSomeFunction = true; } else static if (is(T[0] W) || is(typeof(T[0]) W)) { // T is an expression or a type. Take the type of it and examine. static if (is(W F : F*) && is(F == function)) enum bool isSomeFunction = true; // function pointer else enum bool isSomeFunction = is(W == function) || is(W == delegate); } else enum bool isSomeFunction = false; } 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; } ---
Comment #2 by feco.graczer — 2020-11-12T11:19:08Z
sorry, compiler was DMD v2.093.1 (with ldc2)
Comment #3 by dlang-bot — 2021-11-04T10:02:23Z
@BorisCarvajal created dlang/dmd pull request #13266 "Fix Issue 21380 - A case of compiler crash when using auto ref" fixing this issue: - Fix Issue 21380 - A case of compiler crash when using auto ref https://github.com/dlang/dmd/pull/13266
Comment #4 by dlang-bot — 2021-11-04T11:43:06Z
dlang/dmd pull request #13266 "Fix Issue 21380 - A case of compiler crash when using auto ref" was merged into stable: - 64f1c197657eddc20597d0cf345e0314b8a7ba05 by Boris Carvajal: Fix Issue 21380 - A case of compiler crash when using auto ref https://github.com/dlang/dmd/pull/13266
Comment #5 by dlang-bot — 2021-11-08T20:45:40Z
dlang/dmd pull request #13279 "Merge `stable` into `master`" was merged into master: - 0a9502c66713d2052ee5e9f3e0d188613d2ceca7 by Boris Carvajal: Fix Issue 21380 - A case of compiler crash when using auto ref https://github.com/dlang/dmd/pull/13279