Closed p5pRT closed 12 years ago
The following script issues warnings (2 of them) for vec assignments\, while normal assignments to scalars don't generate any warnings. Since perl guarantees that the extra bits are filled with zeros\, I believe it should not issue these warnings.
While the script demonstrates simple cases\, the testing if the hash element exists and pre-initializing it before the vec assignment complicates production scripts\, and I'd strongly prefer to avoid "no warnings".
Use of uninitialized value in vec at vec_warn.pl line 16. Use of uninitialized value in scalar assignment at vec_warn.pl line 16. Use of uninitialized value in vec at vec_warn.pl line 17. Use of uninitialized value in scalar assignment at vec_warn.pl line 17.
$ cat vec_warn.pl
use warnings; use strict;
my ($s\, %sh); $s = 1; $sh{foo} = 1;
#If an element off the end of #the string is written to\, Perl will first extend #the string with sufficiently many zero bytes. # yet perl generates 2 warnings each for the following 2 vec assignments. # Use of uninitialized value in vec # Use of uninitialized value in scalar assignment my ($v\, %vh); vec($v\,0\,1) = 1; vec($vh{foo}\,0\,1) = 1;
# to avoid warnings must pre-init vectors
my ($wv\, %wvh); $wv = $wvh{foo} = ''; vec($wv\,0\,1) = 1; vec($wvh{foo}\,0\,1) = 1;
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
On Fri May 31 02:26:08 2002\, dcd@tc.fluke.com wrote:
The following script issues warnings (2 of them) for vec assignments\, while normal assignments to scalars don't generate any warnings. Since perl guarantees that the extra bits are filled with zeros\, I believe it should not issue these warnings.
While the script demonstrates simple cases\, the testing if the hash element exists and pre-initializing it before the vec assignment complicates production scripts\, and I'd strongly prefer to avoid "no warnings".
Use of uninitialized value in vec at vec_warn.pl line 16. Use of uninitialized value in scalar assignment at vec_warn.pl line 16. Use of uninitialized value in vec at vec_warn.pl line 17. Use of uninitialized value in scalar assignment at vec_warn.pl line 17.
$ cat vec_warn.pl
use warnings; use strict;
my ($s\, %sh); $s = 1; $sh{foo} = 1;
#If an element off the end of #the string is written to\, Perl will first extend #the string with sufficiently many zero bytes. # yet perl generates 2 warnings each for the following 2 vec assignments. # Use of uninitialized value in vec # Use of uninitialized value in scalar assignment my ($v\, %vh); vec($v\,0\,1) = 1; vec($vh{foo}\,0\,1) = 1;
# to avoid warnings must pre-init vectors
my ($wv\, %wvh); $wv = $wvh{foo} = ''; vec($wv\,0\,1) = 1; vec($wvh{foo}\,0\,1) = 1;
-- Alexandr Ciornii\, http://chorny.net
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
On Fri May 31 02:26:08 2002\, dcd@tc.fluke.com wrote:
The following script issues warnings (2 of them) for vec assignments\, while normal assignments to scalars don't generate any warnings. Since perl guarantees that the extra bits are filled with zeros\, I believe it should not issue these warnings.
While the script demonstrates simple cases\, the testing if the hash element exists and pre-initializing it before the vec assignment complicates production scripts\, and I'd strongly prefer to avoid "no warnings".
Use of uninitialized value in vec at vec_warn.pl line 16. Use of uninitialized value in scalar assignment at vec_warn.pl line 16. Use of uninitialized value in vec at vec_warn.pl line 17. Use of uninitialized value in scalar assignment at vec_warn.pl line 17.
$ cat vec_warn.pl
use warnings; use strict;
my ($s\, %sh); $s = 1; $sh{foo} = 1;
#If an element off the end of #the string is written to\, Perl will first extend #the string with sufficiently many zero bytes. # yet perl generates 2 warnings each for the following 2 vec assignments. # Use of uninitialized value in vec # Use of uninitialized value in scalar assignment my ($v\, %vh); vec($v\,0\,1) = 1; vec($vh{foo}\,0\,1) = 1;
# to avoid warnings must pre-init vectors
my ($wv\, %wvh); $wv = $wvh{foo} = ''; vec($wv\,0\,1) = 1; vec($wvh{foo}\,0\,1) = 1;
-- Alexandr Ciornii\, http://chorny.net
On Mon Jun 13 11:53:26 2011\, chorny wrote:
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
Same warnings in 5.16.0\, albeit slightly more helpful\, since they point at the uninit variable. Attached two two patches: the first one makes sv_pvn_force_flags guard against sv_2pv_flags returning NULL\, which can happen if it's passed SV_UNDEF_RETURNS_NULL; The second patch silences the uninit warnings for vec() by using SV_UNDEF_RETURNS_NULL.
However\, I make no judgment whenever silencing these is a good move; But if it isn't\, this ticket should be rejected.
--hugmeir
On Fri May 25 18:49:56 2012\, Hugmeir wrote:
On Mon Jun 13 11:53:26 2011\, chorny wrote:
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
Same warnings in 5.16.0\, albeit slightly more helpful\, since they point at the uninit variable. Attached two two patches: the first one makes sv_pvn_force_flags guard against sv_2pv_flags returning NULL\, which can happen if it's passed SV_UNDEF_RETURNS_NULL; The second patch silences the uninit warnings for vec() by using SV_UNDEF_RETURNS_NULL.
However\, I make no judgment whenever silencing these is a good move; But if it isn't\, this ticket should be rejected.
I agree that silencing the warning for lvalue vec makes sense\, but it should still warn for rvalue\, I think.
I admit to having only skimmed your patch quickly. Does it do that? This bit here suggests it does:
@@ -1032\,10 +1032\,8 @@ Use of uninitialized value $g2 in substr at - line 9. Use of uninitialized value $m1 in substr at - line 9. Use of uninitialized value $m2 in vec at - line 11. Use of uninitialized value $g1 in vec at - line 11. -Use of uninitialized value $m1 in vec at - line 11. Use of uninitialized value $m2 in vec at - line 12. Use of uninitialized value $g1 in vec at - line 12. -Use of uninitialized value $m1 in vec at - line 12. Use of uninitialized value $m1 in index at - line 14. Use of uninitialized value $m2 in index at - line 14. Use of uninitialized value $g1 in index at - line 15.
--
Father Chrysostomos
On Sat\, May 26\, 2012 at 3:22 PM\, Father Chrysostomos via RT \< perlbug-followup@perl.org> wrote:
On Fri May 25 18:49:56 2012\, Hugmeir wrote:
On Mon Jun 13 11:53:26 2011\, chorny wrote:
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
Same warnings in 5.16.0\, albeit slightly more helpful\, since they point at the uninit variable. Attached two two patches: the first one makes sv_pvn_force_flags guard against sv_2pv_flags returning NULL\, which can happen if it's passed SV_UNDEF_RETURNS_NULL; The second patch silences the uninit warnings for vec() by using SV_UNDEF_RETURNS_NULL.
However\, I make no judgment whenever silencing these is a good move; But if it isn't\, this ticket should be rejected.
I agree that silencing the warning for lvalue vec makes sense\, but it should still warn for rvalue\, I think.
I admit to having only skimmed your patch quickly. Does it do that? This bit here suggests it does:
It silenced both; but you make a good point. I've attached a modified version of the second patch that only silences the warning for lvalue vec.
On Sat May 26 13:41:51 2012\, Hugmeir wrote:
On Sat\, May 26\, 2012 at 3:22 PM\, Father Chrysostomos via RT \< perlbug-followup@perl.org> wrote:
On Fri May 25 18:49:56 2012\, Hugmeir wrote:
On Mon Jun 13 11:53:26 2011\, chorny wrote:
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
Same warnings in 5.16.0\, albeit slightly more helpful\, since they point at the uninit variable. Attached two two patches: the first one makes sv_pvn_force_flags guard against sv_2pv_flags returning NULL\, which can happen if it's passed SV_UNDEF_RETURNS_NULL; The second patch silences the uninit warnings for vec() by using SV_UNDEF_RETURNS_NULL.
However\, I make no judgment whenever silencing these is a good move; But if it isn't\, this ticket should be rejected.
I agree that silencing the warning for lvalue vec makes sense\, but it should still warn for rvalue\, I think.
I admit to having only skimmed your patch quickly. Does it do that? This bit here suggests it does:
It silenced both; but you make a good point. I've attached a modified version of the second patch that only silences the warning for lvalue vec.
Thank you. Applied as 5204593b and 032061d2.
--
Father Chrysostomos
@cpansprout - Status changed from 'open' to 'resolved'
On 26 May 2012 22:41\, Brian Fraser \fraserbn@​gmail\.com wrote:
On Sat\, May 26\, 2012 at 3:22 PM\, Father Chrysostomos via RT \perlbug\-followup@​perl\.org wrote:
On Fri May 25 18:49:56 2012\, Hugmeir wrote:
On Mon Jun 13 11:53:26 2011\, chorny wrote:
Same 2 warnings for each line on perl 5.14.0.
http://rt.perl.org/rt3/Ticket/Display.html?id=9423
Same warnings in 5.16.0\, albeit slightly more helpful\, since they point at the uninit variable. Attached two two patches: the first one makes sv_pvn_force_flags guard against sv_2pv_flags returning NULL\, which can happen if it's passed SV_UNDEF_RETURNS_NULL; The second patch silences the uninit warnings for vec() by using SV_UNDEF_RETURNS_NULL.
However\, I make no judgment whenever silencing these is a good move; But if it isn't\, this ticket should be rejected.
I agree that silencing the warning for lvalue vec makes sense\, but it should still warn for rvalue\, I think.
I admit to having only skimmed your patch quickly. Does it do that? This bit here suggests it does:
It silenced both; but you make a good point. I've attached a modified version of the second patch that only silences the warning for lvalue vec.
Thanks a lot for this patch\, this bit me recently\, and I appreciate you fixing it.
Cheers\, yves
-- perl -Mre=debug -e "/just|another|perl|hacker/"
Migrated from rt.perl.org#9423 (status was 'resolved')
Searchable as RT9423$