> Resubmitting a bug report of mine back from February;
> this time through the proper channel (perlbug, not p5p).
> 
> [paste]
> 
> While editing my Damn Book I re-remembered that couple of months back
> I ran into an anomaly in the handling of bitvectors.
> 
> Fiction: you have a bitvector which you want to shift.
> 
> The current (5.005_03-MT5) fact:
> 
> perl -wle '$b = ""; vec($b, 0, 1) = 1;print unpack("b*",
> $b);$b<<=1;print unpack("b*", $b)'
> 10000000
> 00001100
> 
> Huh?  Adding -w tells more, as usual:
> Argument "^A" isn't numeric in left_shift at -e line 1.
> 
> So left_shift assumes that the argument to shift is a number, but "^A"
> isn't, so it gets converted to string zero "0" (48, 0x30, 0b0000110).
> 
> I consider this behaviour to be rather broken.  I think
> 
>         $b <<= 1
> 
> should shift the whole bitvector left by one position and
> 
>         vec($b, 2, 8) >>= 2
> 
> should shift the bits 16..23 right by two positions (of course not
> leaking into bits 8..15).
> 

Just so we're clear, and to add a proper TODO test case, what would you
consider the proper output to be?

Reply via email to