[PATCH 1/4] Support lambda templates.

Adam Butcher adam@jessamine.co.uk
Thu Sep 5 19:14:00 GMT 2013


On 03.09.2013 22:25, Jason Merrill wrote:
> On 09/03/2013 03:50 PM, Adam Butcher wrote:
>> Problem is that no RTL is set for the incoming parms in the
>> instantiation of the expansion.  It ICEs in gimple_expand_cfg 
>> because 'DECL_RTL_IF_SET
>> (var)' returns nullptr for the incoming parms resulting in a failed 
>> assertion that
>> SA.partition_to_pseudo[i] is non-null.
>
> Sounds like a problem with how _FUN's parameters are instantiated.
> I'm not sure why it would be special.
>
> Does using a function parameter pack in the lambda body work
> currently?  If so, how are the expanded parameters different?
>
Yes it does work.  And I think (hope) I've cracked it; 
make_pack_expansion needs to be called in the body of the thunk (i.e. 
after start_preparsed_function).

If I butcher the implementation so that I rewrite any parameter packs 
with their expansion prior to building the call in return statement, it 
seems to work.

Certainly the following does what I expect it to, the trees look right 
and, more importantly, it doesn't ICE!

    auto g = [] <typename... P> (P...) -> float { return 3.f; };

    float (*pg3) (double, double, double) = g;

    return pg3(1,2,3);

I'll try to clean up what I've got then submit a rolled up patch.

Cheers,
Adam



More information about the Gcc-patches mailing list