Nested functions and tail-call optimization
Ludovic Courtès
ludo@gnu.org
Tue Aug 21 14:12:00 GMT 2012
Hi, Ian,
Ian Lance Taylor <iant@google.com> skribis:
> On Mon, Aug 20, 2012 at 2:25 AM, Ludovic Courtès <ludo@gnu.org> wrote:
>>
>> Consider this function:
>>
>> static tree filter (bool (*pred) (const_tree), tree);
>>
>> static tree
>> list_remove (bool (*pred) (const_tree), tree t)
>> {
>> bool opposite (const_tree t)
>> {
>> return !pred (t);
>> }
>>
>> return filter (opposite, t);
>> }
>>
>> Here, the call to ‘filter’ is likely subject to tail-call optimization.
>> Is there any guarantee that ‘opposite’ is still reachable when ‘filter’
>> is called?
>
> It would clearly be a bug for GCC to do a sibling call from
> list_remove to filter.
OK.
> I don't know whether GCC has that bug or not.
I haven’t witnessed it, just wondering.
Thanks,
Ludo’.
More information about the Gcc-help
mailing list