From 40baebf6601f1e631adc917cf1ad9f2236018158 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sat, 20 Oct 2012 13:45:02 +0200 Subject: [PATCH] add a TODO test for uninitialized warning hash bucket fencepost error This test assumes that a fresh hash with one key with keys from 0 to 20 will put a key in every bucket in the hash. Had we better hash introspection rules we could write this differently and more correctly. Nevertheless this shows the off-by-one error in key detection used by the uninitialized warnings logic on my box. Next patch will untodo the test and fix the bug. --- t/lib/warnings/9uninit | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 43cb670..db5c634 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -2042,4 +2042,34 @@ format = write; EXPECT Use of uninitialized value $x in string at - line 6. +######## +# TODO bugfix will come next patch +# NAME off-by-one error in hash bucket walk in key detection logic +use warnings 'uninitialized'; +for ( 0 .. 20 ) { # we assume that this means we test keys for every bucket + my %h= ( $_ => undef ); + my $s= sprintf "%s", $h{$_}; +} +EXPECT +Use of uninitialized value $h{"0"} in sprintf at - line 5. +Use of uninitialized value $h{"1"} in sprintf at - line 5. +Use of uninitialized value $h{"2"} in sprintf at - line 5. +Use of uninitialized value $h{"3"} in sprintf at - line 5. +Use of uninitialized value $h{"4"} in sprintf at - line 5. +Use of uninitialized value $h{"5"} in sprintf at - line 5. +Use of uninitialized value $h{"6"} in sprintf at - line 5. +Use of uninitialized value $h{"7"} in sprintf at - line 5. +Use of uninitialized value $h{"8"} in sprintf at - line 5. +Use of uninitialized value $h{"9"} in sprintf at - line 5. +Use of uninitialized value $h{"10"} in sprintf at - line 5. +Use of uninitialized value $h{"11"} in sprintf at - line 5. +Use of uninitialized value $h{"12"} in sprintf at - line 5. +Use of uninitialized value $h{"13"} in sprintf at - line 5. +Use of uninitialized value $h{"14"} in sprintf at - line 5. +Use of uninitialized value $h{"15"} in sprintf at - line 5. +Use of uninitialized value $h{"16"} in sprintf at - line 5. +Use of uninitialized value $h{"17"} in sprintf at - line 5. +Use of uninitialized value $h{"18"} in sprintf at - line 5. +Use of uninitialized value $h{"19"} in sprintf at - line 5. +Use of uninitialized value $h{"20"} in sprintf at - line 5. -- 2.7.4