Skip to content

[clang] [Modules] Assertion failure when naming a function make_integer_sequence #102684

Closed
@davidstone

Description

@davidstone

Given the following valid translation units:

export module a;

namespace n {

template<typename, int...>
struct integer_sequence;

template<typename>
using make_integer_sequence = __make_integer_seq<integer_sequence, int, 0>;

} // namespace

export void make_integer_sequence();
export module b;

import a;

template<typename T>
void b() {
	f(make_integer_sequence<T>());
}

clang crashes with

/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot   -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 -MD -MT CMakeFiles/bug.dir/b.cpp.o -MF CMakeFiles/bug.dir/b.cpp.o.d @CMakeFiles/bug.dir/b.cpp.o.modmap -o CMakeFiles/bug.dir/b.cpp.o -c /app/b.cpp
clang-20: /root/llvm-project/clang/lib/Serialization/ASTWriter.cpp:6285: bool clang::ASTWriter::wasDeclEmitted(const clang::Decl*) const: Assertion `(Emitted || (!D->getOwningModule() && isWritingStdCXXNamedModules()) || GeneratingReducedBMI) && "The declaration within modules can only be omitted in reduced BMI."' failed.
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-20240809/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-module-interface -disable-free -clear-ast-before-backend -main-file-name b.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/app/build -fcoverage-compilation-dir=/app/build -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240809/lib/clang/20 -dependency-file CMakeFiles/bug.dir/b.cpp.o.d -MT CMakeFiles/bug.dir/b.cpp.o -sys-header-deps -module-file-deps -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../include/c++/15.0.0/backward -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240809/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=a=CMakeFiles/bug.dir/a.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/bug.dir/b.pcm -x c++ /app/b.cpp
1.	<eof> parser at end of file
 #0 0x0000000003abb448 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x3abb448)
 #1 0x0000000003ab8bbc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007ff09e442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007ff09e4969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007ff09e442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007ff09e4287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007ff09e42871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007ff09e439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000048450ae clang::ASTWriter::wasDeclEmitted(clang::Decl const*) const (.part.0) ASTWriter.cpp:0:0
 #9 0x0000000004898d99 clang::ASTWriter::WriteDeclAndTypes(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x4898d99)
#10 0x0000000004899f40 clang::ASTWriter::WriteASTCore(clang::Sema&, llvm::StringRef, clang::Module*) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x4899f40)
#11 0x000000000489ae4a clang::ASTWriter::WriteAST(clang::Sema&, llvm::StringRef, clang::Module*, llvm::StringRef, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x489ae4a)
#12 0x00000000048c1289 clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x48c1289)
#13 0x00000000048c1351 clang::CXX20ModulesGenerator::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x48c1351)
#14 0x00000000046939b8 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x46939b8)
#15 0x00000000064c73bc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x64c73bc)
#16 0x0000000004659819 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x4659819)
#17 0x00000000045dde2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x45dde2e)
#18 0x0000000004742cee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0x4742cee)
#19 0x0000000000c926af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0xc926af)
#20 0x0000000000c8b83a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000000c8f16e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0xc8f16e)
#22 0x0000000000b63644 main (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0xb63644)
#23 0x00007ff09e429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x00007ff09e429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x0000000000c8b2ee _start (/opt/compiler-explorer/clang-assertions-trunk-20240809/bin/clang-20+0xc8b2ee)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)

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

Note that module a is equivalent to

module;

#include <utility>

export module a;

export void make_integer_sequence();

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header ModulescrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions