cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] Can't capture in `assert` in function expression

Open JohelEGP opened this issue 2 years ago • 1 comments
trafficstars

Title: Can't capture in assert in function expression.

Minimal reproducer (https://cpp2.godbolt.org/z/js9zco1GK):

main: () = {
  pred = :<T> (y: T) requires !std::is_same_v<T, int> = {};
  _ = :(x) = {
    [[assert: inspect x -> bool {
      is (pred$) = std::terminate(); // Condition not instantiated for `int`.
      is _      = true;
    }]]
  }(1);
}
Commands:
cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp

Expected result:

The capture of pred.

Actual result and error:

cppfront: source/cppfront.cpp:2831: void cpp2::cppfront::emit(cpp2::postfix_expression_node&, bool): Assertion `found != n.cap_grp->members.cend() && "ICE: could not find this postfix-expression in capture group"' failed.
Program terminated with signal: SIGSEGV
Compiler returned: 139

JohelEGP avatar Jun 29 '23 15:06 JohelEGP

Also within an initializer (https://cpp2.godbolt.org/z/vhThj648W):

main: (args) = {
  x := :() :std::vector = args$;
}

JohelEGP avatar Nov 14 '23 22:11 JohelEGP