<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63594>63594</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang 16 crashes compiling template code that is fine with Clang15, GCC12, and GCC13
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RalphSteinhagen
</td>
</tr>
</table>
<pre>
I encountered an internal compiler crash in Clang 16 when compiling a C++20 project that previously compiled without issues using Clang 15, GCC 12, and GCC 13. It appears to be related to handling of template code with **'constexpr if'** and concepts.
### Environment
* Clang version: 16.0.6
* Operating System: SUSE Linux
* Architecture: x86_64
### Stack Trace
```bash
====================[ Build | qa_settings | Debug-System - Clang ]==============
/usr/bin/cmake --build /home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang --target qa_settings -j 22
[0/2] Re-checking globbed directories...
[1/2] Building CXX object test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o
FAILED: test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o
/usr/bin/clang++ -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/test -I/home/steinhagen/git/graph-prototype/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/pmt-src/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/fmt-src/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/ut-src/include -isystem /home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/refl-cpp-src/include -g -std=gnu++20 -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wno-unknown-pragmas -Wimplicit-fallthrough -MD -MT test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o -MF test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o.d -o test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o -c /home/steinhagen/git/graph-prototype/test/qa_settings.cpp
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: /usr/bin/clang++ -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/test -I/home/steinhagen/git/graph-prototype/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/pmt-src/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/fmt-src/include -I/home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/ut-src/include -isystem /home/steinhagen/git/graph-prototype/cmake-build-debug-system---clang/_deps/refl-cpp-src/include -g -std=gnu++20 -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wno-unknown-pragmas -Wimplicit-fallthrough -MD -MT test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o -MF test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o.d -o test/CMakeFiles/qa_settings.dir/qa_settings.cpp.o -c /home/steinhagen/git/graph-prototype/test/qa_settings.cpp
1. <eof> parser at end of file
2. /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/bits/unique_ptr.h:1069:5: instantiating function definition 'std::make_unique<fair::graph::node_wrapper<fair::graph::setting_test::Source<float>>>'
3. /home/steinhagen/git/graph-prototype/include/graph.hpp:504:5: instantiating function definition 'fair::graph::node_wrapper<fair::graph::setting_test::Source<float>>::node_wrapper'
4. /home/steinhagen/git/graph-prototype/include/node.hpp:270:5: instantiating function definition 'fair::graph::node<fair::graph::setting_test::Source<float>>::node'
5. /home/steinhagen/git/graph-prototype/include/node.hpp:272:5: instantiating function definition 'fair::graph::node<fair::graph::setting_test::Source<float>>::node'
6. /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/bits/unique_ptr.h:1069:5: instantiating function definition 'std::make_unique<fair::graph::basic_settings<fair::graph::setting_test::Source<float>>, fair::graph::setting_test::Source<float> &>'
7. /home/steinhagen/git/graph-prototype/include/settings.hpp:182:24: instantiating function definition 'fair::graph::basic_settings<fair::graph::setting_test::Source<float>>::basic_settings'
#0 0x00007f044ee3d0e9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM.so.16+0x383d0e9)
#1 0x00007f044ee3acc0 llvm::sys::RunSignalHandlers() (/lib64/libLLVM.so.16+0x383acc0)
#2 0x00007f044ed566f1 (/lib64/libLLVM.so.16+0x37566f1)
#3 0x00007f044b0412f0 __restore_rt (/lib64/libc.so.6+0x3e2f0)
#4 0x00007f0454bdb1b0 clang::Sema::BuildExprRequirement(clang::Expr*, bool, clang::SourceLocation, clang::concepts::ExprRequirement::ReturnTypeRequirement) (/lib64/libclang-cpp.so.16+0x21db1b0)
#5 0x00007f0454f8bc9c (/lib64/libclang-cpp.so.16+0x258bc9c)
#6 0x00007f0454f81095 (/lib64/libclang-cpp.so.16+0x2581095)
#7 0x00007f0454f9a7e5 (/lib64/libclang-cpp.so.16+0x259a7e5)
#8 0x00007f0454f972da (/lib64/libclang-cpp.so.16+0x25972da)
#9 0x00007f0454f8dd06 (/lib64/libclang-cpp.so.16+0x258dd06)
#10 0x00007f0454f8858b (/lib64/libclang-cpp.so.16+0x258858b)
#11 0x00007f0454f7d70a (/lib64/libclang-cpp.so.16+0x257d70a)
#12 0x00007f0454fb850c clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&) (/lib64/libclang-cpp.so.16+0x25b850c)
#13 0x00007f0454fa985c clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::DeclContext*, clang::LocalInstantiationScope*, bool, clang::VarTemplateSpecializationDecl*) (/lib64/libclang-cpp.so.16+0x25a985c)
#14 0x00007f0454fa89f0 clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool, llvm::ArrayRef<clang::BindingDecl*>*) (/lib64/libclang-cpp.so.16+0x25a89f0)
#15 0x00007f0454fb9f61 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/lib64/libclang-cpp.so.16+0x25b9f61)
clang-16.0: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 16.0.6
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
clang-16.0: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16.0: note: diagnostic msg: /tmp/qa_settings-2d8784.cpp
clang-16.0: note: diagnostic msg: /tmp/qa_settings-2d8784.sh
clang-16.0: note: diagnostic msg:
********************
ninja: build stopped: subcommand failed.
```
Full code is here: [clang16_regression.zip](https://github.com/llvm/llvm-project/files/11902090/clang16_regression.zip)
### Additional Information
The crash seems to occur in template code with **`constexpr if`** and concepts. Specifically, the code between lines 288919-288936 in the attached source code. Disabling this section makes the code compile with Clang 16.
Here is the specific section of the code (constructor) where the crash occurs:
```cpp
// ...
auto iterate_over_member = [&](auto member) {
using RawType = std::remove_cvref_t<decltype(member(*_node))>;
// disable clang format because v16 cannot handle in-line requires clauses with return types nicely yet
// clang-format off
if constexpr (requires(Node t) { { unwrap_if_wrapped_t<decltype(t.meta_information)> {} } -> std::same_as<property_map>; }) {
if constexpr (requires(Node t) { { t.description } -> std::same_as<const std::string_view &>; }) {
_node->meta_information.value["description"] = std::string(_node->description);
}
if constexpr (AnnotatedType<RawType>) {
_node->meta_information.value[fmt::format("{}::description", get_display_name(member))] = std::string(RawType::description());
_node->meta_information.value[fmt::format("{}::documentation", get_display_name(member))] = std::string(RawType::documentation());
_node->meta_information.value[fmt::format("{}::unit", get_display_name(member))] = std::string(RawType::unit());
_node->meta_information.value[fmt::format("{}::visible", get_display_name(member))] = RawType::visible();
}
}
// clang-format on
};
// [..]
```
Any help or workaround would be highly appreciated. Thank you for your time and effort in improving Clang! :+1:
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWttP4zgX_2vCy1GqxKFt-sBDaekOErMzAnbYt8pJThovjp21nUL3r_9k50JTynzAMKtPn0YqNI2Pf-fic_GNas02AvHMG5974-UJrU0h1dk15VVxY5CJgm5QnCQy251dAopU1sKgwgyoAGYfBeWQyrJiHBWkiuoCmIAFp2ID4QQeChRtOxMboLDwyLlHzkkAlZJ_YWrAFNRApXDLZK35rkPL4IGZQtYGmNY1aqi1RWiRxx5ZwG-LBYTEPlGRNb-iEVwaoFWFVGkwEhIEhZwazOyvgorMCSJzMFhWtgFSmaFjBh6Zu880lUIbfKwUsNwj0-a945JKkWJl9MgLll4wb_-TqPnAhdgyJUWJwjRNYEFbqbeoNJPCi-YQTkbBaLJP8qVCRY2V7WanDZaW6uaPmwu4YqJ-3Kecq7RgBlNTK7RUj_FkPTk9Ls-Noek93CqaYts0CZpPQnXRvoqW7_-Mz-G8ZjwDb7qAv-lao7FKaPd7iUm98Rt9wG-t4I3fgt_qs6q18sgqYcIjq7Sk9wi-nzSMyaqQJXpkpXuP9chqw4z9r2hV-JWSRppdhV3npqufOfm0k8_3_dTJ5_uGqg2agTb-X0BIK8z4PPDIinjjJVyjnxaY3tth23CZJJhBxhSmRiqGejQa9X3Cro8zl3PlP_8EmTQxgNpKu_hM73HFOGqPrPbYjzKmDt6kVTWSDfhqfnl1sbSe8E4YOG5la40mWsG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