On 4/12/24 09:47, Patrick Palka wrote:
The original PR114393 testcase is unfortunately still not accepted after r14-9938-g081c1e93d56d35 due to return type deduction confusion when a lambda-expr is used as a default template argument. The below reduced testcase demonstrates the bug. Here, when forming the dependent specialization b_v<U> we substitute the default argument of F, a lambda-expr, with _Descriptor=U. (In this case in_template_context is true since we're in the context of the template c_v so we don't defer.) This substitution in turn lowers the level of its auto return type from 2 to 1. So later, when instantiating c_v<int, char> we incorrectly replace the auto with the template argument at level=0, index=0, i.e. int, instead of going through do_auto_deduction which would yield char. One way to fix this would be to use a level-less auto to represent a deduced return type of a lambda, but that might be too invasive of a change at this stage.
I suspect we want to move to all level-less autos, apart from those that imply an actual template parameter. But agreed, not in stage 4.
The patch is OK. Jason