https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119401
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #4) > The underlying problem is that we tsubst_lambda_expr three times for the > same arguments, producing three different lambdas: > > 1) when forming the type of A<>::f > 2) when forming the parameters of A<>::f FWIW maybe_rebuild_function_decl_type ought to fix up the function type of f to agree with the formal parameter type in this case. > 3) when instantiating A<>::f > > before r15-7202 we silently ended up with #3 and got the mangling wrong. > But now they all have the same mangling, so they collide. > > The fix should be to only instantiate the lambda once, whether that's > something specific to lambdas or more generally by only doing > tsubst_arg_types/lookup_template_class once for B<...>. I wonder if regenerate_decl_from_template could avoid doing the parameter declaration merging stuff if the function has not been redeclared/can't be redeclared? In particular for a function whose signature contains a lambda, IIUC it definitely can't be redeclared.