Skip to content

[clang] [Interp] assertion failure on lambda capture of lambda (-fexperimental-new-constant-interpreter) #82203

Closed
@sethp

Description

@sethp

Given:

void wrapper() {
  constexpr auto f = []() constexpr {
    return 0;
  };

  constexpr auto g = [f]() constexpr {
    return f();
  };
  static_assert(g() == f());
}

With -fexperimental-new-constant-interpreter clang crashes evaluating the declaration of g:

clang++: /root/llvm-project/clang/include/clang/AST/APValue.h:553: clang::APValue& clang::APValue::getStructField(unsigned int): Assertion `i < getStructNumFields() && "field index OOB"' failed.
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-assertions-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 -fexperimental-new-constant-interpreter <source>
...

(see: https://godbolt.org/z/nz8v5sffc )

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions