[llvm-bugs] [Bug 45915] New: clang crashes after parsing bad C++17 deduction guide declaration

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 13 17:35:35 PDT 2020


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

            Bug ID: 45915
           Summary: clang crashes after parsing bad C++17 deduction guide
                    declaration
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dgreenaway at google.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The following code:

```
template <a> class b;
b() b c;
```

compiled with `clang++ -std=c++17` causes clang to crash with the following
error:

---

<source>:1:11: error: unknown type name 'a'

template <a> class b;

          ^

<source>:2:1: error: deduction guide declaration without trailing return type

b() b c;                                                                        

^

<source>:2:4: error: expected ';' after top level declarator

b() b c;                                                                        

   ^

   ;

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.

Stack dump:

0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
./output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics
-fno-crash-diagnostics -O2 -std=c++17 <source> 

1.      <source>:2:8: current parser token ';'

 #0 0x000055a39034714a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2bce14a)

 #1 0x000055a390344f14 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2bcbf14)

 #2 0x000055a390345185 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2bcc185)

 #3 0x000055a3902bd720 CrashRecoverySignalHandler(int)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2b44720)

 #4 0x00007ff85980f890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)

 #5 0x000055a3922736b6 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4afa6b6)

 #6 0x000055a3920045a3 clang::Sema::ActOnUninitializedDecl(clang::Decl*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x488b5a3)

 #7 0x000055a391dfc2ba
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x46832ba)

 #8 0x000055a391e0f175 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4696175)

 #9 0x000055a391de60f9
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x466d0f9)

#10 0x000055a391de6df1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.227)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x466ddf1)

#11 0x000055a391deccd9
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4673cd9)

#12 0x000055a391dee3e9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x46753e9)

#13 0x000055a391de2059 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x4669059)

#14 0x000055a390b1a839 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x33a1839)

#15 0x000055a390ad5b03
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x335cb03)

#16 0x000055a390bded4b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3465d4b)

#17 0x000055a38e5a5e8c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xe2ce8c)

#18 0x000055a38e5a2abd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe29abd)

#19 0x000055a3909b0455 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3237455)

#20 0x000055a3902bd803
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x2b44803)

#21 0x000055a3909b10c0
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.152)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x32380c0)

#22 0x000055a39098b8c5
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x32128c5)

#23 0x000055a39098c30f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x321330f)

#24 0x000055a390994e15
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x321be15)

#25 0x000055a38e4e7020 main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xd6e020)

#26 0x00007ff8586cdb97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)

#27 0x000055a38e5a263a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0xe2963a)

clang-11: 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/20200514/ba2f7a18/attachment-0001.html>


More information about the llvm-bugs mailing list