Re: [PATCH] c++, contracts: Fix incorrect parameter mapping for postconditions in functions with template parameter packs. [PR124395]
Jason Merrill <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
On 8/14/26 4:47 PM, Wang Jinghao wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu. > > -- >8 -- > > `check_postconditions_in_redecl()' assumes that the parameters in a > function redeclaration correspond one to one with those in the > previous declaration. This assumption does not hold for parameter > packs. As a result, if the original declaration contains a parameter > pack and the pack is instantiated with no arguments, a segmentation > fault occurs. > > Likewise, when the parameter pack is instantiated with multiple > arguments, type checking is skipped for all instantiated parameters > except the first one. > > PR c++/124395 > > gcc/cp/ChangeLog: > > * contracts.cc (maybe_propagate_used_in_post_flag): New > function. Contains the logic moved from > check_postconditions_in_redecl for checking parameters in > redeclarations. > (check_postconditions_in_redecl): Fix parameter pack handing > > gcc/testsuite/ChangeLog: > > * g++.dg/contracts/cpp26/pr124395.C: New test. And then fold2.C.