<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62359>62359</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash on compilation with modules and openmp
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Yaraslaut
</td>
</tr>
</table>
<pre>
The following code crashes compilation
`hello.cppm`
```
module;
#include <iostream>
export module hello;
export void hello() {
std::cout << "Hello World!\n";
}
```
`use.cpp`
Crash is present even without `#pragma`
```
import hello;
int main() {
#pragma omp parallel for
for(int i=0;i<10;i++)
hello();
return 0;
}
```
Compilation command:
```
clang++ -std=c++20 hello.cppm --precompile -o hello.pcm
clang++ -std=c++20 use.cpp -fopenmp -fprebuilt-module-path=. hello.pcm -o hello_omp.out
```
Crash exist on
`clang version 15.0.7`
`clang version 16.0.3`
Partial stack
```
0. Program arguments: /usr/local/bin/clang-16 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name use.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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/yaraslau/Downloads/make_modules -resource-dir /usr/local/lib/clang/16 -internal-isystem /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1 -internal-isystem /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/x86_64-pc-linux-gnu -internal-isystem /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/backward -internal-isystem /usr/local/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/yaraslau/Downloads/make_modules -ferror-limit 19 -fopenmp -fgnuc-version=4.2.1 -fno-implicit-modules -fprebuilt-module-path=. -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/use-b496b6.o -x c++ use.cpp
1. use.cpp:1:13: current parser token ';'
#0 0x00007f2fd41b8cb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/yaraslau/repo/llvm-project/llvm/lib/Support/Unix/Signals.inc:567:13
#1 0x00007f2fd41b7090 llvm::sys::RunSignalHandlers() /home/yaraslau/repo/llvm-project/llvm/lib/Support/Signals.cpp:105:18
#2 0x00007f2fd41b9438 SignalHandler(int) /home/yaraslau/repo/llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
#3 0x00007f2fd3451f50 (/usr/lib/libc.so.6+0x38f50)
#4 0x00007f2fd780a44b clang::Diagnostic::getArgKind(unsigned int) const /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/Diagnostic.h:1592:9
#5 0x00007f2fd780a44b clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const /home/yaraslau/repo/llvm-project/clang/lib/Basic/Diagnostic.cpp:930:44
#6 0x00007f2fd780bbfa clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const /home/yaraslau/repo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:0:32
#7 0x00007f2fd942b41b llvm::raw_ostream::raw_ostream(bool, llvm::raw_ostream::OStreamKind) /home/yaraslau/repo/llvm-project/llvm/include/llvm/Support/raw_ostream.h:122:9
#8 0x00007f2fd942b41b llvm::raw_pwrite_stream::raw_pwrite_stream(bool, llvm::raw_ostream::OStreamKind) /home/yaraslau/repo/llvm-project/llvm/include/llvm/Support/raw_ostream.h:435:9
#9 0x00007f2fd942b41b llvm::raw_svector_ostream::raw_svector_ostream(llvm::SmallVectorImpl<char>&) /home/yaraslau/repo/llvm-project/llvm/include/llvm/Support/raw_ostream.h:688:12
#10 0x00007f2fd942b41b clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) /home/yaraslau/repo/llvm-project/clang/lib/Frontend/TextDiagnosticPrinter.cpp:119:29
#11 0x00007f2fd7810760 clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&, clang::DiagnosticIDs::Level) const /home/yaraslau/repo/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:839:12
#12 0x00007f2fd7810760 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const /home/yaraslau/repo/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp:830:3
#13 0x00007f2fd7809e72 clang::DiagnosticsEngine::ProcessDiag() /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/Diagnostic.h:1037:19
#14 0x00007f2fd7809e72 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) /home/yaraslau/repo/llvm-project/clang/lib/Basic/Diagnostic.cpp:549:15
#15 0x00007f2fd78456ea clang::DiagnosticBuilder::Clear() const /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/Diagnostic.h:1299:13
#16 0x00007f2fd78456ea clang::DiagnosticBuilder::Emit() /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/Diagnostic.h:1323:5
#17 0x00007f2fd78456ea clang::DiagnosticBuilder::~DiagnosticBuilder() /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/Diagnostic.h:1361:26
#18 0x00007f2fd918975d checkLanguageOptions(clang::LangOptions const&, clang::LangOptions const&, clang::DiagnosticsEngine*, bool) /home/yaraslau/repo/llvm-project/clang/include/clang/Basic/LangOptions.def:0:0
#19 0x00007f2fd919f24c clang::ASTReader::ParseLanguageOptions(llvm::SmallVector<unsigned long, 64u> const&, bool, clang::ASTReaderListener&, bool) /home/yaraslau/repo/llvm-project/clang/lib/Serialization/ASTReader.cpp:5861:19
#20 0x00007f2fd919cdf9 clang::ASTReader::ReadOptionsBlock(llvm::BitstreamCursor&, unsigned int, bool, clang::ASTReaderListener&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) /home/yaraslau/repo/llvm-project/clang/lib/Serialization/ASTReader.cpp:0:11
#21 0x00007f2fd91a14c3 clang::ASTReader::ReadControlBlock(clang::serialization::ModuleFile&, llvm::SmallVectorImpl<clang::ASTReader::ImportedModule>&, clang::serialization::ModuleFile const*, unsigned int) /home/yaraslau/repo/llvm-project/clang/lib/Serialization/ASTReader.cpp:2744:22
#22 0x00007f2fd91a4250 clang::ASTReader::ReadASTCore(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, clang::serialization::ModuleFile*, llvm::SmallVectorImpl<clang::ASTReader::ImportedModule>&, long, long, clang::ASTFileSignature, unsigned int) /home/yaraslau/repo/llvm-project/clang/lib/Serialization/ASTReader.cpp:0:15
#23 0x00007f2fd91ad915 clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::ASTReader::ImportedSubmodule>*) /home/yaraslau/repo/llvm-project/clang/lib/Serialization/ASTReader.cpp:4273:21
#24 0x00007f2fd935ded1 clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, clang::SourceLocation, clang::SourceLocation, bool) /home/yaraslau/repo/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1846:27
#25 0x00007f2fd935ed73 clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation>>, clang::Module::NameVisibilityKind, bool) /home/yaraslau/repo/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:0:31
#26 0x00007f2fd84c3ab7 clang::Sema::ActOnModuleImport(clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation>>, bool) /home/yaraslau/repo/llvm-project/clang/lib/Sema/SemaModule.cpp:527:8
#27 0x00007f2fd79e9825 clang::Parser::ParseModuleImport(clang::SourceLocation, clang::Sema::ModuleImportState&) /home/yaraslau/repo/llvm-project/clang/lib/Parse/Parser.cpp:0:0
```
Some bits from [@whisperiry ](https://github.com/whisperity)
```
clang-17: /home/whisperity/mnt/llvm-project/!Worktrees/master/clang/lib/Basic/Diagnostic.cpp:622: void HandleSelectModifier(const clang::Diagnostic&, unsigned int, const char*, unsigned int, llvm::SmallVectorImpl<char>&): Assertion `NextVal != ArgumentEnd && "Value for integer select modifier was" " larger than the number of options in the diagnostic string!"' failed.
```
```
#22 0x00007f2504d8b064 checkLanguageOptions(clang::LangOptions const&, clang::LangOptions const&, clang::DiagnosticsEngine*, bool) /home/whisperity/mnt/llvm-project/!Worktrees/master/clang/include/clang/Basic/LangOptions.def:241:1
#23 0x00007f2504d93df3 clang::PCHValidator::ReadLanguageOptions(clang::LangOptions const&, bool, bool) /home/whisperity/mnt/llvm-project/!Worktrees/master/clang/lib/Serialization/ASTReader.cpp:448:1
#24 0x00007f2504db46de clang::ASTReader::ParseLanguageOptions(llvm::SmallVector<unsigned long, 64u> const&, bool, clang::ASTReaderListener&, bool) /home/whisperity/mnt/llvm-project/!Worktrees/master/clang/lib/Serialization/ASTReader.cpp:5895:38
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWl1z2yq3_jXkhsEjgSTLF7lw7Po0c9q3naane85VBknI5g0CDaDEORfnt78DkizJcb53M917umMJEKz1rMVaDx_UGL6VjJ2D-ALE6zPa2J3S5_9LNTWCNvYsU8X9-c8dg6USQt1xuYW5KhjMNTU7ZmCuqpoLarmSIFiDYAmSYMeEULO8riuQBIfS7p9_rVTRCAbIRVeLCZe5aAoGAVlxZaxmtALkU1vN9rXSFrYfQd_74dOu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