Issue 61463
Summary Clang crashed when initializing constexpr
Labels new issue
Assignees
Reporter namniav
    Reduced as I can.

**https://gcc.godbolt.org/z/xohcqnqnn**
```c++
#include <string_view>

template<typename T>
consteval std::string_view get_pretty_function_name() {
  return __PRETTY_FUNCTION__;
}

struct probe_config {
  std::string_view prefix;

  consteval probe_config(std::string_view templat, std::string_view probe) {
    auto pos = templat.find(probe);
    if (pos == std::string_view::npos)
      throw "template doesn't contain probe";
    prefix = templat.substr(0, pos);
  }
};

struct struct_probe;
enum enum_probe_t { enum_probe, };

template<auto Val>
struct val_probe_wrapper;


constexpr probe_config struct_probe_config {
  get_pretty_function_name<struct_probe>(),
 "struct_probe"
};

constexpr probe_config enum_probe_config {
 get_pretty_function_name<val_probe_wrapper<enum_probe>>(),
 "enum_probe"
};
```

```c++
<source>:26:24: warning: unused variable 'struct_probe_config' [-Wunused-const-variable]
constexpr probe_config struct_probe_config {
 ^
<source>:31:24: warning: unused variable 'enum_probe_config' [-Wunused-const-variable]
constexpr probe_config enum_probe_config {
 ^
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-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 -std=c++20 -Wall -Wextra -O3 <source>
1.	<eof> parser at end of file
 #0 0x0000560c69d2df9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a96f9f)
 #1 0x0000560c69d2bfcc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a94fcc)
 #2 0x0000560c69c7e658 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f04b1b5e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000560c6d20ab13 FastEvaluateAsRValue(clang::Expr const*, clang::Expr::EvalResult&, clang::ASTContext const&, bool&) ExprConstant.cpp:0:0
 #5 0x0000560c6d25eaaf clang::Expr::EvaluateAsConstantExpr(clang::Expr::EvalResult&, clang::ASTContext const&, clang::Expr::ConstantExprKind) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6fc7aaf)
 #6 0x0000560c6c756335 clang::Sema::PopExpressionEvaluationContext() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x64bf335)
 #7 0x0000560c6c1f70c6 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f600c6)
 #8 0x0000560c6ae90285 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bf9285)
 #9 0x0000560c6a77f361 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44e8361)
#10 0x0000560c6a701c53 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x446ac53)
#11 0x0000560c6a85f51b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45c851b)
#12 0x0000560c6763910c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x13a210c)
#13 0x0000560c676348cf ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#14 0x0000560c6a55e8dd 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
#15 0x0000560c69c7eab7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39e7ab7)
#16 0x0000560c6a55eb1c 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
#17 0x0000560c6a52622c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x428f22c)
#18 0x0000560c6a526c1d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x428fc1d)
#19 0x0000560c6a53103c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x429a03c)
#20 0x0000560c67636e7f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x139fe7f)
#21 0x0000560c67538945 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12a1945)
#22 0x00007f04b160c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#23 0x0000560c67630b1e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1399b1e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to