Skip to content

clang ICE when decltype'ing a capture inside a lambda using deducing this #125439

Open
@foonathan

Description

@foonathan

Source:

void foo()
{
    int x;
    [x](this auto const&) { decltype(x) y; }();
}

Compile:

$ clang++ -std=c++23 test.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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -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++23 <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:4:5: Generating code for declaration 'foo()::(anonymous class)::operator()'
#0 0x0000000003b10418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b10418)
#1 0x0000000003b0e55c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b0e55c)
#2 0x0000000003a5d898 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000703df5242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000006ef39dc clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6ef39dc)
#5 0x0000000006ede4eb clang::ASTContext::getTypeInfo(clang::Type const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6ede4eb)
#6 0x0000000006ef393f clang::ASTContext::getAlignOfGlobalVar(clang::QualType, clang::VarDecl const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6ef393f)
#7 0x00000000353ecd50 
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)

https://godbolt.org/z/x6Pfh7Yqn

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]regression:19Regression in 19 release

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions