Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

Perl_form not accurately described in pod; maybe the implementation is wrong #22170

Open khwilliamson opened 3 weeks ago

khwilliamson commented 3 weeks ago

Description

The documentation for Perl_form() says that it returns in the same buffer each time, so you have to copy it if you need to save its value. But the code reads:

if (PL_phase != PERL_PHASE_DESTRUCT) return newSVpvs_flags("", SVs_TEMP);

This is from mess_alloc in util.c that is what is eventually called to get the space to return the value.

Only in global destruction is the the buffer reused. This seems wrong.

This is the state of affairs in v5.39.9

tonycoz commented 3 weeks ago

The temp allocation was added in e72dc28c8f6f33daa2b69b80b6322e338e999561, I think it just needs documentation.