| Issue |
209095
|
| Summary |
[clang] ICE on libstdc++ `std::source_location` without access control
|
| Labels |
|
| Assignees |
|
| Reporter |
ilazaric
|
```cpp
namespace std {
struct source_location
{
struct __impl
{
const char* _M_file_name;
const char* _M_function_name;
unsigned _M_line;
unsigned _M_column;
};
using __builtin_ret_type = decltype(__builtin_source_location());
// [support.srcloc.cons], creation
static consteval source_location
current(__builtin_ret_type __p = __builtin_source_location()) noexcept
{
source_location __ret;
__ret._M_impl = static_cast <const __impl*>(__p);
return __ret;
}
const __impl* _M_impl = nullptr;
};
}
template<auto foo = std::source_location::current()>
void fn() {}
int main() {
fn();
}
```
Compiler options: "-std=c++26 -O3"
clang crashes with output:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++26 -O3 <source>
1. <eof> parser at end of file
2. <source>:29:5: LLVM IR generation of declaration 'main'
3. <source>:29:5: Generating code for declaration 'main'
4. <source>:27:6: Mangling declaration 'fn'
#0 0x0000000003c80738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c80738)
#1 0x0000000003c7e07c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c7e07c)
#2 0x0000000003bc1d68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000074dd96645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x00000000078ab19b (anonymous namespace)::CXXNameMangler::mangleName(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#5 0x00000000078ae7ee (anonymous namespace)::CXXNameMangler::mangleValueInTemplateArg(clang::QualType, clang::APValue const&, bool, bool) ItaniumMangle.cpp:0:0
#6 0x00000000078ae3fe (anonymous namespace)::CXXNameMangler::mangleValueInTemplateArg(clang::QualType, clang::APValue const&, bool, bool) ItaniumMangle.cpp:0:0
#7 0x00000000078a98cd (anonymous namespace)::CXXNameMangler::mangleTemplateArg(clang::TemplateArgument, bool) ItaniumMangle.cpp:0:0
#8 0x00000000078a9acf (anonymous namespace)::CXXNameMangler::mangleTemplateArgs(clang::TemplateName, clang::TemplateArgumentList const&) ItaniumMangle.cpp:0:0
#9 0x00000000078ab103 (anonymous namespace)::CXXNameMangler::mangleNameWithAbiTags(clang::GlobalDecl, llvm::ArrayRef<llvm::StringRef>) ItaniumMangle.cpp:0:0
#10 0x00000000078ab9b2 (anonymous namespace)::CXXNameMangler::mangleName(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#11 0x00000000078ac51e (anonymous namespace)::CXXNameMangler::mangleFunctionEncoding(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#12 0x00000000078b0572 (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::GlobalDecl, llvm::raw_ostream&) ItaniumMangle.cpp:0:0
#13 0x00000000042b308b getMangledNameImpl(clang::CodeGen::CodeGenModule&, clang::GlobalDecl, clang::NamedDecl const*, bool) CodeGenModule.cpp:0:0
#14 0x00000000042cbb61 clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42cbb61)
#15 0x0000000004300a27 clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4300a27)
#16 0x000000000408934c clang::CodeGen::CodeGenModule::getRawFunctionPointer(clang::GlobalDecl, llvm::Type*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x408934c)
#17 0x00000000040a1b91 EmitDirectCallee(clang::CodeGen::CodeGenFunction&, clang::GlobalDecl) CGExpr.cpp:0:0
#18 0x00000000040bb0bd clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40bb0bd)
#19 0x00000000040badcf clang::CodeGen::CodeGenFunction::EmitCallee(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40badcf)
#20 0x00000000040bd137 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot, llvm::CallBase**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40bd137)
#21 0x0000000004123eb9 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) CGExprScalar.cpp:0:0
#22 0x0000000004118d10 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#23 0x000000000411d482 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x411d482)
#24 0x00000000040913ce clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40913ce)
#25 0x00000000040b7f68 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x40b7f68)
#26 0x000000000422be31 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x422be31)
#27 0x000000000423361b clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x423361b)
#28 0x000000000428f37d clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x428f37d)
#29 0x00000000042a2e3b clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42a2e3b)
#30 0x0000000004301d3a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4301d3a)
#31 0x00000000042fbeb4 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42fbeb4)
#32 0x00000000042fccb0 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42fccb0)
#33 0x0000000004307d65 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#34 0x00000000046593e1 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#35 0x0000000004643cf9 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4643cf9)
#36 0x000000000627e7f4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x627e7f4)
#37 0x0000000004657305 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4657305)
#38 0x000000000498d8b1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x498d8b1)
#39 0x000000000491d8c5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x491d8c5)
#40 0x0000000004a626db clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4a626db)
#41 0x0000000000df25a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdf25a8)
#42 0x0000000000dea40b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#43 0x0000000000dea4ad int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#44 0x00000000046d2a49 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
#45 0x0000000003bc2123 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bc2123)
#46 0x00000000046d348d 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
#47 0x000000000468e3a2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x468e3a2)
#48 0x0000000004692655 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+++0x4692655)
#49 0x000000000469d6ac clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x469d6ac)
#50 0x0000000000deef41 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdeef41)
#51 0x0000000000d1399a main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd1399a)
#52 0x000074dd9662a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#53 0x000074dd9662a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#54 0x0000000000de9eb5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xde9eb5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 139
```
Godbolt: https://godbolt.org/z/sajW3zv75
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs