Skip to content
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

Assertion in clang/lib/Sema/SemaTemplateVariadic.cpp failed: `!Unexpanded.empty() && "Unable to find unexpanded parameter packs"' #22200

Closed
llvmbot opened this issue Dec 10, 2014 · 9 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 10, 2014

Bugzilla Link 21826
Version trunk
OS All
Blocks #23431
Attachments test case
Reporter LLVM Bugzilla Contributor
CC @Quuxplusone,@davidstone,@DougGregor,@zygoloid,@rnk

Extended Description

Fuzzing discovered that the attached test case, when given as input to

clang -fno-crash-diagnostics -std=c++11 -xc++ -c -emit-llvm

causes this assertion failure:

unexpanded-parm-pack.cpp:1:24: error: expected ']'
template <int... N> a[N
^
unexpanded-parm-pack.cpp:1:22: note: to match this '['
template <int... N> a[N
^
unexpanded-parm-pack.cpp:1:21: error: C++ requires a type specifier for all declarations
template <int... N> a[N
^
clang-3.6: tools/clang/lib/Sema/SemaTemplateVariadic.cpp:281: bool clang::Sema::DiagnoseUnexpandedParameterPack(clang::SourceLocation, clang::TypeSourceInfo *, clang::Sema::UnexpandedParameterPackContext): Assertion `!Unexpanded.empty() && "Unable to find unexpanded parameter packs"' failed.

@rnk
Copy link
Collaborator

rnk commented Oct 22, 2016

still repros

@Quuxplusone
Copy link
Contributor

Still repros. Here's another test case that fails with the same assertion:

template <class... Ts>
struct S {
typedef Ts A;
A a;
};

@davidstone
Copy link
Contributor

Here is a valid code reproduction

template <class... Ts>
void f(Ts...) {
	(..., [] {
		using Us = Ts;
		Us{};
	});
}

See it live: https://godbolt.org/z/b6YWGnWz7

@davidstone
Copy link
Contributor

Full backtrace

clang++: /root/llvm-project/clang/lib/Sema/SemaTemplateVariadic.cpp:407: bool clang::Sema::DiagnoseUnexpandedParameterPack(clang::Expr*, clang::Sema::UnexpandedParameterPackContext): Assertion `!Unexpanded.empty() && "Unable to find unexpanded parameter packs"' failed.
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-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -isystem/opt/compiler-explorer/libs/boost_1_71_0 -std=c++20 <source>
1.	<source>:6:2: current parser token '}'
2.	<source>:2:15: parsing function body 'f'
3.	<source>:2:15: in compound statement ('{}')
4.	<source>:3:8: lambda expression parsing
5.	<source>:3:11: in compound statement ('{}')
 #&#8203;0 0x00005604ab383f6c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3744f6c)
 #&#8203;1 0x00005604ab381e24 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3742e24)
 #&#8203;2 0x00005604ab3820a5 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37430a5)
 #&#8203;3 0x00005604ab2dc868 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #&#8203;4 0x00007fe428e373c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #&#8203;5 0x00007fe42890718b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4618b)
 #&#8203;6 0x00007fe4288e6859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #&#8203;7 0x00007fe4288e6729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #&#8203;8 0x00007fe4288f7f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #&#8203;9 0x00005604ad982ed2 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d43ed2)
#&#8203;10 0x00005604ad5d2b86 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5993b86)
#&#8203;11 0x00005604ad7cc8f4 clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5b8d8f4)
#&#8203;12 0x00005604ad1f86c3 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b96c3)
#&#8203;13 0x00005604ad1f53e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b63e4)
#&#8203;14 0x00005604ad1f569c clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b669c)
#&#8203;15 0x00005604ad1f2ad1 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b3ad1)
#&#8203;16 0x00005604ad1b42fa clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55752fa)
#&#8203;17 0x00005604ad1b4873 clang::Parser::ParseLambdaExpression() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5575873)
#&#8203;18 0x00005604ad19f438 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5560438)
#&#8203;19 0x00005604ad1a08a6 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55618a6)
#&#8203;20 0x00005604ad1a18b8 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55628b8)
#&#8203;21 0x00005604ad1a25e9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55635e9)
#&#8203;22 0x00005604ad1a26e8 clang::Parser::ParseFoldExpression(clang::ActionResult<clang::Expr*, true>, clang::BalancedDelimiterTracker&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55636e8)
#&#8203;23 0x00005604ad1a6692 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5567692)
#&#8203;24 0x00005604ad19e9a6 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x555f9a6)
#&#8203;25 0x00005604ad1a08a6 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55618a6)
#&#8203;26 0x00005604ad1a18b8 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55628b8)
#&#8203;27 0x00005604ad1a25e9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55635e9)
#&#8203;28 0x00005604ad1f864d clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b964d)
#&#8203;29 0x00005604ad1f53e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b63e4)
#&#8203;30 0x00005604ad1f569c clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b669c)
#&#8203;31 0x00005604ad1f2ad1 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55b3ad1)
#&#8203;32 0x00005604ad1faf6b clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55bbf6b)
#&#8203;33 0x00005604ad15f644 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5520644)
#&#8203;34 0x00005604ad209509 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55ca509)
#&#8203;35 0x00005604ad2131b3 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55d41b3)
#&#8203;36 0x00005604ad213589 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55d4589)
#&#8203;37 0x00005604ad181e46 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5542e46)
#&#8203;38 0x00005604ad15c12d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x551d12d)
#&#8203;39 0x00005604ad15cd49 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x551dd49)
#&#8203;40 0x00005604ad15d0b5 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x551e0b5)
#&#8203;41 0x00005604ad153243 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5514243)
#&#8203;42 0x00005604ac2f0518 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46b1518)
#&#8203;43 0x00005604abc70971 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4031971)
#&#8203;44 0x00005604abc0c6f2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fcd6f2)
#&#8203;45 0x00005604abd3bdaa clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40fcdaa)
#&#8203;46 0x00005604a8fe3fdc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13a4fdc)
#&#8203;47 0x00005604a8fdf319 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#&#8203;48 0x00005604abac4255 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) Job.cpp:0:0
#&#8203;49 0x00005604ab2dc943 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x369d943)
#&#8203;50 0x00005604abac4bf4 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.161) Job.cpp:0:0
#&#8203;51 0x00005604aba9ceda clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e5deda)
#&#8203;52 0x00005604aba9db7f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e5eb7f)
#&#8203;53 0x00005604abaa651a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e6751a)
#&#8203;54 0x00005604a8f0d235 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x12ce235)
#&#8203;55 0x00007fe4288e80b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#&#8203;56 0x00005604a8fdee8a _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x139fe8a)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@kcc
Copy link
Contributor

kcc commented Nov 26, 2021

mentioned in issue #23431

@Quuxplusone
Copy link
Contributor

mentioned in issue llvm/llvm-bugzilla-archive#28471

@kcc kcc mentioned this issue Mar 28, 2015
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@mordante
Copy link
Member

I just ran into the same issue. The godbolt link provided still reproduces the issue.

@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Mar 23, 2022
@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 23, 2022

@llvm/issue-subscribers-clang-frontend

@fhahn fhahn changed the title [fuzz] Assertion `!Unexpanded.empty() && "Unable to find unexpanded parameter packs"' failed. Assertion in clang/lib/Sema/SemaTemplateVariadic.cpp failed: `!Unexpanded.empty() && "Unable to find unexpanded parameter packs"' Mar 24, 2022
@fhahn fhahn added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Mar 24, 2022
@oToToT
Copy link
Member

oToToT commented Aug 21, 2022

Closing as this seems to have already been fixed. (I checked the godbolt link above)

@oToToT oToToT closed this as completed Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

9 participants