[C++ PR 78252] illformed lamda?
Jason Merrill
jason@redhat.com
Wed Nov 23 15:46:00 GMT 2016
On Wed, Nov 23, 2016 at 10:34 AM, Nathan Sidwell <nathan@acm.org> wrote:
> On 11/22/2016 02:26 PM, Nathan Sidwell wrote:
>>
>> template<typename T>
>> void for2 (T &v)
>> {
>> }
>>
>> void Foo ()
>> {
>> auto lam_1 = [](int &) { };
>> auto lam_2 = [](auto &) { }; // IIUC this is implicitly templatey
>>
>> for2 (lam_1);
>> for2 (lam_2); // What is the lambda's argument type?
>> }
>>
>> We get 2 instantiations of for2:
>> .type _Z4for2IZ3FoovEUlRiE_EvRT_, @function
>> .type _Z4for2IZ3FoovEUlRT_E0_EvS1_, @function
>
>
> Ok. looking further, I now think this is well formed.
>
> lam_2's 'auto &' parameter creates an implicit templated function operator
> member function. We could have used 'Da' to refer to the auto parms, but we
> didn't. I think that means that the demangler needs to be taught that
> 'T[n]_' occurring inside a lambda's argument encoding means 'auto' and does
> not refer to any containing template instantiation name?
That sounds good. I wonder why is_auto doesn't already return true for them?
Jason
More information about the Gcc-bugs
mailing list