nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

B::C minor fixes when using -w flag #292

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Failed to compile CORE/op/magic-27839.t at ce3837c

> prove -v t/C-COMPILED/CORE--op--magic-27839.t
t/C-COMPILED/CORE--op--magic-27839.t ..
1..13
ok 1 - t/CORE/op/magic-27839.t exists
ok 2 - Not in taint mode
ok 3 - /usr/local/cpanel/3rdparty/perl/514/bin/perl -c  t/CORE/op/magic-27839.t
# Dying on warning: Use of uninitialized value $pv in pack at 
/usr/local/cpanel/3rdparty/perl/514/lib/perl5/cpanel_lib/i386-linux-64int-debug/
B/C.pm line 2065.
# CHECK failed--call queue aborted.
not ok 4 - t/CORE/op/magic-27839.c is generated (-O3,-fno-fold)
ok 5 # skip Can't test further due to failure to create a c file.
ok 6 # skip Can't test further due to failure to create a c file.
ok 7 # skip Can't test further due to failure to create a c file.
ok 8 # skip Can't test further due to failure to create a c file.
ok 9 # skip Can't test further due to failure to create a c file.
ok 10 # skip Can't test further due to failure to create a c file.
ok 11 # skip Can't test further due to failure to create a c file.
ok 12 # skip Can't test further due to failure to create a c file.
ok 13 # skip Can't test further due to failure to create a c file.

#   Failed test 't/CORE/op/magic-27839.c is generated (-O3,-fno-fold)'
#   at t/C-COMPILED/CORE--op--magic-27839.t line 70.
# Looks like you failed 1 test of 13.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/13 subtests
    (less 9 skipped subtests: 3 okay)

Test Summary Report
-------------------
t/C-COMPILED/CORE--op--magic-27839.t (Wstat: 256 Tests: 13 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
Files=1, Tests=13,  2 wallclock secs ( 0.05 usr  0.00 sys +  1.51 cusr  0.03 
csys =  1.59 CPU)
Result: FAIL

Here is the fix for that and a similar issue

diff --git lib/B/C.pm lib/B/C.pm
index 8728e15..c4751ff 100644
--- lib/B/C.pm
+++ lib/B/C.pm
@@ -762,7 +762,7 @@ sub save_pv_or_rv {
     $shared_hek = $PERL510 ? (($sv->FLAGS & 0x09000000) == 0x09000000) : undef;
     $shared_hek = $shared_hek ? 1 : IsCOW_hek($sv);
     $static = $B::C::const_strings and ($sv->FLAGS & SVf_READONLY) ? 1 : 0;
-    $static = 0 if $shared_hek or $fullname =~ / :pad/ or ($fullname =~ 
/^DynaLoader/ and $pv =~ /^boot_/);
+    $static = 0 if $shared_hek or ( $fullname && ( $fullname =~ / :pad/ or 
($fullname =~ /^DynaLoader/ and $pv =~ /^boot_/) ) );
     if ($shared_hek and $pok and !$cur) { #272 empty key
       warn "use emptystring for empty shared key $fullname\n" if $debug{hv};
       $savesym = "emptystring";
@@ -2062,7 +2062,7 @@ sub savepvn {
   my @init;

   # work with byte offsets/lengths
-  $pv = pack "a*", $pv;
+  $pv = pack "a*", $pv if defined $pv;
   if ( defined $max_string_len && length($pv) > $max_string_len ) {
     push @init, sprintf( "Newx(%s,%u,char);", $dest, length($pv) + 2 );
     my $offset = 0;

Also note a B issue when trying to compile that code
#!./perl -w

BEGIN {
    $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };

    sub foo {
        my $s = shift;
        $s =~ s/^a/b/mig;
        return;
    }
}

print "ok\n";

Original issue reported on code.google.com by nicolas....@gmail.com on 6 Feb 2014 at 10:39

GoogleCodeExporter commented 9 years ago
Thanks, fixed with commit 55ec78f935554f30a1a57654f52827811ab0066e
Author: Reini Urban <rurban@cpanel.net>
Date:   Thu Feb 6 18:01:37 2014 -0600

    op/magic-27839.t: fix undefined pv and fullname warnings #292

The testfile is called t/C-COMPILED/CORE--op--magic-27839==BC-271.t btw

please merge the testcore filenames added with the merge of the testcore branch

Original comment by reini.urban on 7 Feb 2014 at 12:03