On Thu, Jul 17, 2025 at 05:31:27PM -0400, Jason Merrill wrote:
> On 7/16/25 10:49 AM, Marek Polacek wrote:
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> > 
> > -- >8 --
> > This patch implements consteval blocks, as specified by P2996.
> > They aren't very useful without define_aggregate, but having
> > a reviewed implementation on trunk would be great.
> > 
> > consteval {} can be anywhere where a member-declaration or
> > block-declaration can be.  The expression corresponding to it is:
> > 
> >    [] -> void static consteval compound-statement ()
> > 
> > and it must be a constant expression.
> > 
> > I've used cp_parser_lambda_expression to take care of most of the
> > parsing.  Since a consteval block can find itself in a template, we
> > need a vehicle to carry the block for instantiation.  Rather than
> > inventing a new tree, I'm using STMT_EXPR.
> 
> If we need something to trigger immediate evaluation, why not a
> STATIC_ASSERT as the proposal suggests?

Isn't it a problem that static_assert constant evaluates it multiple times
(at least when it isn't constant)?
Once finish_static_assert -> fold_non_dependent_expr -> maybe_constant_value
and then again finish_static_assert -> cxx_constant_value ?

        Jakub

Reply via email to