[llvm-bugs] [Bug 42747] New: Segfault in Sema::DeclareImplicitDeductionGuides when the relevant constructor has a typo

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 24 11:33:24 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42747

            Bug ID: 42747
           Summary: Segfault in Sema::DeclareImplicitDeductionGuides when
                    the relevant constructor has a typo
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

// https://godbolt.org/z/mJ4EOb

template<class T>
struct tuple {
    template<Foo<0,> = 1.2> tuple();
};

tuple t;

========
clang++ -std=c++17 -c test.cc
Clang trunk produces two completely valid error messages, and then segfaults.
I assume the issue is that some parts of the code are happy to typo-fix
`Foo<0,>` to `int`, whereas the deduction-guide code is unhappy with that idea
for some reason.
========

<source>:3:20: error: expected expression
    template<Foo<0,> = 1.2> tuple();
                   ^
<source>:3:24: error: conversion from 'double' to 'int' is not allowed in a
converted constant expression
    template<Foo<0,> = 1.2> tuple();
                       ^~~
Stack dump:
0.      Program arguments:
/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name example.cpp -mrelocation-model static
-mthread-model posix -mframe-pointer=all -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -coverage-notes-file /home/ubuntu/./output.gcno
-resource-dir /opt/compiler-explorer/clang-trunk-20190722/lib/clang/10.0.0
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/x86_64-linux-gnu
-internal-isystem
/opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20190722/lib/clang/10.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/ubuntu
-ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o
./output.s -x c++ <source> 
1.      <source>:6:8: current parser token ';'
 #0 0x000055708e9345ba llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x27dc5ba)
 #1 0x000055708e932374 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x27da374)
 #2 0x000055708e9324b2 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x27da4b2)
 #3 0x00007f880a7a8890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x0000557090444170
clang::Sema::DeclareImplicitDeductionGuides(clang::TemplateDecl*,
clang::SourceLocation)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x42ec170)
 #5 0x00005570902d103f LookupDirect(clang::Sema&, clang::LookupResult&,
clang::DeclContext const*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x417903f)
 #6 0x00005570902d15c0 clang::Sema::LookupQualifiedName(clang::LookupResult&,
clang::DeclContext*, bool) (.part.1132)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x41795c0)
 #7 0x000055709029097c
clang::Sema::DeduceTemplateSpecializationFromInitializer(clang::TypeSourceInfo*,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x413897c)
 #8 0x0000557090034635
clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*,
clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*,
clang::SourceRange, bool, clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3edc635)
 #9 0x0000557090048d6e
clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3ef0d6e)
#10 0x00005570900528b9 clang::Sema::ActOnUninitializedDecl(clang::Decl*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3efa8b9)
#11 0x000055708fe7aeda
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d22eda)
#12 0x000055708fe8880f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d3080f)
#13 0x000055708fe62ed9
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d0aed9)
#14 0x000055708fe63bb1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.207)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d0bbb1)
#15 0x000055708fe6ae26
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d12e26)
#16 0x000055708fe6b889
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d13889)
#17 0x000055708fe5f679 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x3d07679)
#18 0x000055708f68a4c7 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x35324c7)
#19 0x000055708f004e69 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x2eace69)
#20 0x000055708efc83d5
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x2e703d5)
#21 0x000055708f0c8873
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0x2f70873)
#22 0x000055708ce66ea0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0xd0eea0)
#23 0x000055708cdc5792 main
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0xc6d792)
#24 0x00007f8809666b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#25 0x000055708ce6455a _start
(/opt/compiler-explorer/clang-trunk-20190722/bin/clang-10+0xd0c55a)
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
Compiler returned: 254

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190724/5ae83974/attachment-0001.html>


More information about the llvm-bugs mailing list