Open
Description
This is the first of several reports I'll be filing of bugs that we (CCI) noticed in our recent work but that we have no urgency at this point to have fixed. I'm filing them for the community's information; feel free to give them a low priority.
Just about any occurrence of _For_any
or _Itype_for_any
at the top level that is not followed by a left parenthesis seems to cause an assertion failure in the parser. For example, if I try to compile a source file containing just:
_For_any
I get:
bad-for-any.c:1:9: error: unexpected token in _For_any specifier
_For_any
^
(
bad-for-any.c:1:9: error: expected identifier or '('
clang: /home/matt/3c/clang/lib/Parse/ParseDecl.cpp:1873: void clang::Parser::ExitQuantifiedTypeScope(clang::DeclSpec&): Assertion `getCurScope()->isForanyScope() && "Current scope should be created by _For_any specifier."' failed.
PLEASE submit a bug report to https://github.com/Microsoft/checkedc-clang/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /home/matt/3c/build/bin/clang -c -o /dev/null bad-for-any.c
1. <eof> parser at end of file
#0 0x000055b6d2d9e07b llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/matt/3c/llvm/lib/Support/Unix/Signals.inc:564:22
#1 0x000055b6d2d9e0ee PrintStackTraceSignalHandler(void*) /home/matt/3c/llvm/lib/Support/Unix/Signals.inc:625:1
#2 0x000055b6d2d9bbda llvm::sys::RunSignalHandlers() /home/matt/3c/llvm/lib/Support/Signals.cpp:68:20
#3 0x000055b6d2d9bdd9 llvm::sys::CleanupOnSignal(unsigned long) /home/matt/3c/llvm/lib/Support/Unix/Signals.inc:361:31
#4 0x000055b6d2cef0b4 HandleCrash /home/matt/3c/llvm/lib/Support/CrashRecoveryContext.cpp:75:27
#5 0x000055b6d2cef0b4 CrashRecoverySignalHandler(int) /home/matt/3c/llvm/lib/Support/CrashRecoveryContext.cpp:382:62
#6 0x00007fc29099e3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#7 0x00007fc29043e18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#8 0x00007fc29041d859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
#9 0x00007fc29041d729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#10 0x00007fc29041d729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#11 0x00007fc29042ef36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#12 0x000055b6d51ed473 clang::Parser::ExitQuantifiedTypeScope(clang::DeclSpec&) /home/matt/3c/clang/lib/Parse/ParseDecl.cpp:1878:5
#13 0x000055b6d5203194 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/matt/3c/clang/lib/Parse/ParseDecl.cpp:1922:12
#14 0x000055b6d51e04e8 clang::Sema::CheckedScopeRAII::~CheckedScopeRAII() /home/matt/3c/clang/include/clang/Sema/Sema.h:4427:28
#15 0x000055b6d51e04e8 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/matt/3c/clang/lib/Parse/Parser.cpp:1042:57
#16 0x000055b6d51e0abc clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/matt/3c/clang/lib/Parse/Parser.cpp:1154:57
#17 0x000055b6d51e1772 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (.localalias) /home/matt/3c/clang/lib/Parse/Parser.cpp:956:58
#18 0x000055b6d51e1a75 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/matt/3c/clang/lib/Parse/Parser.cpp:704:42
#19 0x000055b6d51e1f23 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) /home/matt/3c/clang/lib/Parse/Parser.cpp:572:43
#20 0x000055b6d51d788c clang::ParseAST(clang::Sema&, bool, bool) /home/matt/3c/clang/lib/Parse/ParseAST.cpp:157:47
#21 0x000055b6d3b61137 clang::ASTFrontendAction::ExecuteAction() /home/matt/3c/clang/lib/Frontend/FrontendAction.cpp:1059:1
#22 0x000055b6d3c6b7ca clang::CodeGenAction::ExecuteAction() /home/matt/3c/clang/lib/CodeGen/CodeGenAction.cpp:1185:1
#23 0x000055b6d3b63adc clang::FrontendAction::Execute() /home/matt/3c/clang/lib/Frontend/FrontendAction.cpp:950:21
#24 0x000055b6d3aa3d1f llvm::Error::setChecked(bool) /home/matt/3c/llvm/include/llvm/Support/Error.h:305:22
#25 0x000055b6d3aa3d1f llvm::Error::operator bool() /home/matt/3c/llvm/include/llvm/Support/Error.h:236:15
#26 0x000055b6d3aa3d1f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/matt/3c/clang/lib/Frontend/CompilerInstance.cpp:984:42
#27 0x000055b6d3c60f20 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/matt/3c/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#28 0x000055b6d1618ef8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/matt/3c/clang/tools/driver/cc1_main.cpp:240:40
#29 0x000055b6d1612f55 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/matt/3c/clang/tools/driver/driver.cpp:330:20
#30 0x000055b6d38d1f4f operator() /home/matt/3c/clang/lib/Driver/Job.cpp:400:32
#31 0x000055b6d38d1f4f 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) /home/matt/3c/llvm/include/llvm/ADT/STLExtras.h:185:52
#32 0x000055b6d2cef212 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/matt/3c/llvm/lib/Support/CrashRecoveryContext.cpp:419:10
#33 0x000055b6d38d53b9 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const /home/matt/3c/clang/lib/Driver/Job.cpp:400:3
#34 0x000055b6d389c54d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const /home/matt/3c/clang/lib/Driver/Compilation.cpp:195:22
#35 0x000055b6d389d104 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const /home/matt/3c/clang/lib/Driver/Compilation.cpp:246:5
#36 0x000055b6d38a7922 llvm::SmallVectorBase<unsigned int>::empty() const /home/matt/3c/llvm/include/llvm/ADT/SmallVector.h:69:47
#37 0x000055b6d38a7922 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /home/matt/3c/clang/lib/Driver/Driver.cpp:1509:28
#38 0x000055b6d1616253 main /home/matt/3c/clang/tools/driver/driver.cpp:502:39
#39 0x00007fc29041f0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#40 0x000055b6d16129ce _start (/home/matt/3c/build/bin/clang+0x2ada9ce)