[llvm-bugs] [Bug 40444] New: Crash on incorrect deduction guide

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 24 08:21:33 PST 2019


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

            Bug ID: 40444
           Summary: Crash on incorrect deduction guide
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++'17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: asynts at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 21377
  --> https://bugs.llvm.org/attachment.cgi?id=21377&action=edit
I was prompted to provide these files.

While experimenting with deduction guides I wrote the following (incorrect)
code:

template <typename _iter> void foo(_iter begin, _iter end) {
  // suppress unused warning
  (void)begin, (void)end;
}

template <typename _container> void foo(const _container &container) {
  foo(container.begin(), container.end());
}

// doesn't make any sense
template <typename _container>
void foo(const _container &container)->foo<decltype(container)>;

int main() { foo({1, 2, 3}); }

Clang crashed with a Segmentation Fault in response:

main.cc:11:40: error: expected a type
void foo(const _container &container)->foo<decltype(container)>;
                                       ^
main.cc:11:1: error: function with trailing return type must specify return
type 'auto', not 'void'
void foo(const _container &container)->foo<decltype(container)>;
^~~~
main.cc:11:63: error: expected ';' at end of declaration
void foo(const _container &container)->foo<decltype(container)>;
                                                              ^
                                                              ;
Stack dump:
0.      Program arguments: /usr/lib/llvm-7/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name main.cc -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/lib/llvm-7/lib/clang/7.0.1 -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
-internal-isystem /usr/include/clang/7.0.1/include/ -internal-isystem
/usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.1/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++2a -fdeprecated-macro -fdebug-compilation-dir /tmp/tmp.62KMEmc37s
-ferror-limit 19 -fmessage-length 190 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/main-018846.o -x c++ main.cc -faddrsig 
1.      main.cc:11:64: current parser token ';'
#0 0x00007fd132bc2c2f llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/x86_64-linux-gnu/libLLVM-7.so.1+0x9cec2f)
#1 0x00007fd132bc1160 llvm::sys::RunSignalHandlers()
(/usr/lib/x86_64-linux-gnu/libLLVM-7.so.1+0x9cd160)
#2 0x00007fd132bc2f42 (/usr/lib/x86_64-linux-gnu/libLLVM-7.so.1+0x9cef42)
#3 0x00007fd135c1b670 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12670)
#4 0x0000000001a6138f
clang::NestedNameSpecifier::containsUnexpandedParameterPack() const
(/usr/lib/llvm-7/bin/clang+0x1a6138f)
#5 0x00000000017bf731
clang::Sema::DiagnoseUnexpandedParameterPack(clang::CXXScopeSpec const&,
clang::Sema::UnexpandedParameterPackContext)
(/usr/lib/llvm-7/bin/clang+0x17bf731)
#6 0x00000000013925be clang::Sema::HandleDeclarator(clang::Scope*,
clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/usr/lib/llvm-7/bin/clang+0x13925be)
#7 0x0000000001392468 clang::Sema::ActOnDeclarator(clang::Scope*,
clang::Declarator&) (/usr/lib/llvm-7/bin/clang+0x1392468)
#8 0x00000000010d2ff0
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-7/bin/clang+0x10d2ff0)
#9 0x00000000010d1d85 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-7/bin/clang+0x10d1d85)
#10 0x00000000010baf4a
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/lib/llvm-7/bin/clang+0x10baf4a)
#11 0x00000000010ba938
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/lib/llvm-7/bin/clang+0x10ba938)
#12 0x00000000010b989c
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib/llvm-7/bin/clang+0x10b989c)
#13 0x00000000010b866e
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-7/bin/clang+0x10b866e)
#14 0x00000000010b4187 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-7/bin/clang+0x10b4187)
#15 0x0000000000acdf0f clang::FrontendAction::Execute()
(/usr/lib/llvm-7/bin/clang+0xacdf0f)
#16 0x0000000000a8f238
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-7/bin/clang+0xa8f238)
#17 0x0000000000b5c426
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-7/bin/clang+0xb5c426)
#18 0x00000000006aa011 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-7/bin/clang+0x6aa011)
#19 0x00000000006a84a7 main (/usr/lib/llvm-7/bin/clang+0x6a84a7)
#20 0x00007fd131d3709b __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2409b)
#21 0x00000000006a5aca _start (/usr/lib/llvm-7/bin/clang+0x6a5aca)
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 7.0.1-4 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

I have a pretty unstable version of debian installed (called debian sid) that
might be related.

-- 
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/20190124/2dd8065c/attachment-0001.html>


More information about the llvm-bugs mailing list