Open llvmbot opened 10 years ago
Still crashing as of post-17 trunk: https://godbolt.org/z/9dfzWd8qh Reduced by me and C-Reduce:
struct bidirectional_iterator {};
template <typename I>
struct counted_cursor {
struct mixin {
friend void advance(counted_cursor<I>::mixin it) {
it.mixin::type;
}
};
};
int main() {
advance(counted_cursor<bidirectional_iterator>::mixin{});
}
Trunk crash:
Unable to find instantiation of declaration!
UNREACHABLE executed at /root/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:6344!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. <source>:6:17: instantiating function definition 'advance'
#0 0x00000000036b2ff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b2ff8)
#1 0x00000000036b0cbc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b0cbc)
#2 0x00000000035fa0e8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f2b27bec420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f2b276af00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f2b2768e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x000000000360538a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x360538a)
#7 0x00000000069a0dfd clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69a0dfd)
#8 0x0000000006906661 (anonymous namespace)::TemplateInstantiator::TransformDecl(clang::SourceLocation, clang::Decl*) SemaTemplateInstantiate.cpp:0:0
#9 0x000000000694b1ab clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCXXDependentScopeMemberExpr(clang::CXXDependentScopeMemberExpr*) SemaTemplateInstantiate.cpp:0:0
#10 0x000000000691bdc9 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) SemaTemplateInstantiate.cpp:0:0
#11 0x00000000069513ef clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*, clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::StmtDiscardKind) SemaTemplateInstantiate.cpp:0:0
#12 0x0000000006952614 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#13 0x000000000695822a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x695822a)
#14 0x00000000069a783b clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69a783b)
#15 0x00000000069a5c9f clang::Sema::PerformPendingInstantiations(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69a5c9f)
#16 0x0000000005f7f7e9 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind) (.part.0) Sema.cpp:0:0
#17 0x0000000005f7ffc2 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5f7ffc2)
#18 0x0000000005e158a8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e158a8)
#19 0x0000000005e09a2a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e09a2a)
#20 0x0000000004912a28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4912a28)
#21 0x000000000417b4a9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x417b4a9)
#22 0x00000000040fb69e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40fb69e)
#23 0x000000000425977e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x425977e)
#24 0x0000000000bd90ae cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd90ae)
#25 0x0000000000bd0c3a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000000003f5c9d9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#27 0x00000000035fa594 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35fa594)
#28 0x0000000003f5cfcf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#29 0x0000000003f25345 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f25345)
#30 0x0000000003f25dad clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f25dad)
#31 0x0000000003f2dcd5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f2dcd5)
#32 0x0000000000bd681c clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd681c)
#33 0x0000000000ad2dd1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xad2dd1)
#34 0x00007f2b27690083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x0000000000bd071e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd071e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
@llvm/issue-subscribers-clang-frontend
So in this case: https://godbolt.org/z/7Pra5jG1E
struct bidirectional_iterator {};
template <typename I>
struct counted_cursor {
struct mixin {
friend void advance(mixin it) {
it.type;
}
};
};
int main() {
advance(counted_cursor<bidirectional_iterator>::mixin{});
}
we obtain a diagnostic, so something about the qualified name is preventing us from diagnosing this, I think.
There are a bunch of places we diagnose err_no_member
.
Actually this may be a better example: https://godbolt.org/z/TxnWYfozr
because it looks like we are crashing in the lookup for mixin
struct bidirectional_iterator {};
template <typename I>
struct counted_cursor {
struct mixin {
friend void advance(mixin it) {
it.mixin;
}
};
};
int main() {
advance(counted_cursor<bidirectional_iterator>::mixin{});
}
but it looks like that diagnostic is also happening in Sema::BuildMemberReferenceExpr(...)
which happens after the crash.
In the case with just it.mixin
on this section:
E->getFirstQualifierFoundInScope()
gives us a nullptr
so we don't progress any further and we eventually hit the diagnostic.
I think the unreachable here:
is not correct. If we let the control flow through then we get a reasonable diagnostic:
qualLookNotExist2.cpp:7:17: error: no member named 'type' in 'counted_cursor<bidirectional_iterator>::mixin'
7 | it.mixin::type;
| ~~ ^
qualLookNotExist2.cpp:13:3: note: in instantiation of member function 'advance' requested here
13 | advance(counted_cursor<bidirectional_iterator>::mixin{});
| ^
CC @zygoloid wdyt?
My last two examples no longer crash on trunk but the original one does.
Still crashing as of post-17 trunk: https://godbolt.org/z/9dfzWd8qh Reduced by me and C-Reduce:
struct bidirectional_iterator {}; template <typename I> struct counted_cursor { struct mixin { friend void advance(counted_cursor<I>::mixin it) { it.mixin::type; } }; }; int main() { advance(counted_cursor<bidirectional_iterator>::mixin{}); }
It is not only a assert crash issue.
This code is valid in gcc but invalid in clang
struct bidirectional_iterator {};
template <typename I>
struct counted_cursor {
struct mixin {
int type;
friend void advance(counted_cursor<I>::mixin it) {
it.mixin::type;
}
};
};
int main() {
advance(counted_cursor<bidirectional_iterator>::mixin{});
}
Extended Description
Stack dump: