Skip to content

Assertion fail for generic struct definition after non-generic pre-declaration #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
john-h-kastner opened this issue Jun 10, 2021 · 0 comments
Labels
priority:3 This labels bugs that are not very critical but still need to be addressed.

Comments

@john-h-kastner
Copy link
Contributor

struct hash;
struct hash _For_any(K) {};
clang: /home/john/checkedc-clang/clang/lib/Sema/CheckedCSubst.cpp:302: bool clang::Sema::DiagnoseExpandingCycles(clang::RecordDecl*, clang::SourceLocation): Assertion `Base->isGenericOrItypeGeneric() && "Can only check expanding cycles for generic structs"' 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: clang -c hash.c 
1.	hash.c:2:27: current parser token ';'
2.	hash.c:2:1: parsing struct/union body 'hash'
 #0 0x000055c26848f381 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/john/checkedc-clang/llvm/build/../lib/Support/Unix/Signals.inc:564:22
 #1 0x000055c26848f418 PrintStackTraceSignalHandler(void*) /home/john/checkedc-clang/llvm/build/../lib/Support/Unix/Signals.inc:625:1
 #2 0x000055c26848d16b llvm::sys::RunSignalHandlers() /home/john/checkedc-clang/llvm/build/../lib/Support/Signals.cpp:68:20
 #3 0x000055c26848eb87 llvm::sys::CleanupOnSignal(unsigned long) /home/john/checkedc-clang/llvm/build/../lib/Support/Unix/Signals.inc:361:31
 #4 0x000055c2683cf728 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/john/checkedc-clang/llvm/build/../lib/Support/CrashRecoveryContext.cpp:77:5
 #5 0x000055c2683cfc1a CrashRecoverySignalHandler(int) /home/john/checkedc-clang/llvm/build/../lib/Support/CrashRecoveryContext.cpp:383:1
 #6 0x00007fc9f787c3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #7 0x00007fc9f731c18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #8 0x00007fc9f72fb859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
 #9 0x00007fc9f72fb729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
#10 0x00007fc9f72fb729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
#11 0x00007fc9f730cf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
#12 0x000055c26b617e71 clang::Sema::DiagnoseExpandingCycles(clang::RecordDecl*, clang::SourceLocation) /home/john/checkedc-clang/clang/lib/Sema/CheckedCSubst.cpp:302:3
#13 0x000055c26b544be2 clang::Parser::ParseStructUnionBody(clang::SourceLocation, clang::TypeSpecifierType, clang::RecordDecl*) /home/john/checkedc-clang/clang/lib/Parse/ParseDecl.cpp:4572:9
#14 0x000055c26b566ad8 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) /home/john/checkedc-clang/clang/lib/Parse/ParseDeclCXX.cpp:2054:20
#15 0x000055c26b542cdf clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) /home/john/checkedc-clang/clang/lib/Parse/ParseDecl.cpp:4067:26
#16 0x000055c26b51a843 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/john/checkedc-clang/clang/lib/Parse/Parser.cpp:1042:57
#17 0x000055c26b51af67 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/john/checkedc-clang/clang/lib/Parse/Parser.cpp:1154:57
#18 0x000055c26b51a2d1 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (.localalias) /home/john/checkedc-clang/clang/lib/Parse/Parser.cpp:956:58
#19 0x000055c26b51942a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /home/john/checkedc-clang/clang/lib/Parse/Parser.cpp:704:42
#20 0x000055c26b514d88 clang::ParseAST(clang::Sema&, bool, bool) /home/john/checkedc-clang/clang/lib/Parse/ParseAST.cpp:158:37
#21 0x000055c2690e0b11 clang::ASTFrontendAction::ExecuteAction() /home/john/checkedc-clang/clang/lib/Frontend/FrontendAction.cpp:1057:11
#22 0x000055c269a5d7e3 clang::CodeGenAction::ExecuteAction() /home/john/checkedc-clang/clang/lib/CodeGen/CodeGenAction.cpp:1185:1
#23 0x000055c2690e0468 clang::FrontendAction::Execute() /home/john/checkedc-clang/clang/lib/Frontend/FrontendAction.cpp:954:38
#24 0x000055c269070d6f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/john/checkedc-clang/clang/lib/Frontend/CompilerInstance.cpp:984:42
#25 0x000055c26927c4db clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/john/checkedc-clang/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#26 0x000055c266b1a91b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/john/checkedc-clang/clang/tools/driver/cc1_main.cpp:240:40
#27 0x000055c266b0f7e3 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/john/checkedc-clang/clang/tools/driver/driver.cpp:330:20
#28 0x000055c268f66659 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'()::operator()() const /home/john/checkedc-clang/clang/lib/Driver/Job.cpp:400:32
#29 0x000055c268f66f22 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/john/checkedc-clang/llvm/include/llvm/ADT/STLExtras.h:186:40
#30 0x000055c2683c2636 llvm::function_ref<void ()>::operator()() const /home/john/checkedc-clang/llvm/build/../include/llvm/ADT/STLExtras.h:203:62
#31 0x000055c2683cfe2c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/john/checkedc-clang/llvm/build/../lib/Support/CrashRecoveryContext.cpp:419:10
#32 0x000055c268f66881 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/john/checkedc-clang/clang/lib/Driver/Job.cpp:400:7
#33 0x000055c268f196af clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const /home/john/checkedc-clang/clang/lib/Driver/Compilation.cpp:195:22
#34 0x000055c268f19a12 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const /home/john/checkedc-clang/clang/lib/Driver/Compilation.cpp:246:53
#35 0x000055c268f298c2 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /home/john/checkedc-clang/clang/lib/Driver/Driver.cpp:1509:28
#36 0x000055c266b107b7 main /home/john/checkedc-clang/clang/tools/driver/driver.cpp:502:39
#37 0x00007fc9f72fd0b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#38 0x000055c266b0de7e _start (/home/john/checkedc-clang/llvm/build/bin/clang-11+0x2601e7e)

The assertion fail goes away if I switch the order, defining the generic struct first before declaring it without the _For_any. It is also fixed if the pre-declaration declares the struct with the generic (struct hash _For_any(K)).

Presumably this related to the unfinished work on generic structs for issue #644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:3 This labels bugs that are not very critical but still need to be addressed.
Projects
None yet
Development

No branches or pull requests

2 participants