On 8/21/26 7:09 AM, Waffl3x wrote:
Bootstrapped and tested on x86_64-pc-linux-gnu, okay for trunk?

-- 8< --

This patch disables postcondition diagnostics when expanding a pack for a
PACK_INDEX_EXPR.  Before an element of the pack is selected, each one is
substituted, triggering diagnostics if any element of the pack is non-const.
This is solved by simply hacking processing_postcondition off temporarily
while the pack is expanded, processing_contract_condition needs to be left
on as it might be a reference that needs to be constified.

The skipped diagnostic is then called at the end of tsubst_pack_index
instead.  Some hoops have to be jumped through to get a similar location,
PACK_INDEX_EXPR should probably have a usable location, but that isn't for
this patch.

Hmm, it should be pretty simple to fix that in cp_parser_pack_index.

And we don't need to even consider diagnosing for PACK_INDEX_TYPE.
        PR c++/126836

gcc/cp/ChangeLog:

        * pt.cc (tsubst_pack_index): Hack processing_postcondition off for
        pack expansion, call check_param_in_postcondition.

gcc/testsuite/ChangeLog:

        * g++.dg/contracts/cpp26/pr126836.C: New test.

rename

Jason

Reply via email to