This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #126064] Apply scalar context to stat args
If we don’t apply scalar context to stat’s argument, then it doesn’t
get its context marked:
$ ./perl -Ilib -MO=Concise -le 'stat stat stat'
7 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
6 <1> stat vK/1 ->7
5 <1> stat K/1 ->6
4 <1> stat K/1 ->5
- <1> ex-rv2sv sK/1 ->4
3 <#> gvsv[*_] s ->4
-e syntax OK
and it might think that it is in void context at run time:
$ ./perl -Ilib -le 'print 1, 2, 3,(stat stat stat), 4, 5, 6'
1456
It ate my stack items!
If it reads past the beginning of the stack, it can crash.
Just apply scalar context, and Bob’s your uncle, of course.