This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #79178] STORE/FETCH of tie()d hash get stringified key
authorFather Chrysostomos <sprout@cpan.org>
Sat, 27 Nov 2010 14:22:24 +0000 (06:22 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 27 Nov 2010 15:15:35 +0000 (07:15 -0800)
commit04698ff67968faa57a46c12d31e17c17baf08876
tree6eb540d4c87ab93304ac06964db9d474fbc7a76f
parenta51ee39bac6a83e6d63d3e6d8941ae352ef3546f
[perl #79178] STORE/FETCH of tie()d hash get stringified key

This bug has been present in non-threaded builds for a long time.
Change 38bb37b9aa introduced it to threaded builds.

$hash{...} makes its operand a shared-PV scalar if it is an OP_CONST.
But \"foo" is also an OP_CONST, as is anything generated with use
constant. This is the sort of thing that results:

$ perl5.8.5 -MO=Concise -e '$a{\"foo"}'
7  <@> leave[1 ref] vKP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 1 -e:1) v ->3
6     <2> helem vK/2 ->7
4        <1> rv2hv sKR/1 ->5
3           <$> gv(*a) s ->4
5        <$> const(PVIV "SCALAR(0x81b378)") s ->6
-e syntax OK

(My 5.8.5 installation is non-threaded.)

See the "SCALAR(0x81b378)" in there?

So this commit skips that optimisation if the key is ROK or if it is a
PVMG or higher.
op.c
t/op/hash.t