develooper Front page | perl.perl5.porters | Postings from December 2002

[PATCH] operation on `PL_na' may be undefined

From:
Nicholas Clark
Date:
December 10, 2002 12:04
Subject:
[PATCH] operation on `PL_na' may be undefined
Message ID:
20021210195917.GJ288@Bagpuss.unfortu.net
gcc-3.0 warns as follows:

universal.c: In function `XS_UNIVERSAL_VERSION':
universal.c:342: warning: operation on `PL_na' may be undefined

The offending line is

	if ( vcmp( SvRV(req), SvRV(sv) ) > 0 )
	    Perl_croak(aTHX_ "%s version %s required--this is only version %s",
		HvNAME(pkg), SvPV(req,PL_na), SvPV(sv,PL_na));

Both SvPV macros are assigning to PL_na. Using PL_na in the first place isn't
a great idea, as it's in thread local storage on a threaded perl.

The appended patch compiles without warnings, passes all tests, and results
in a slightly smaller object file:

-rw-rw-r--  7 nick  nick  14080 Dec 10 19:29 universal.o.orig
-rw-rw-r--  2 nick  nick  13948 Dec 10 18:47 universal.o

Nicholas Clark
-- 
Befunge better than perl?	http://www.perl.org/advocacy/spoofathon/

--- universal.c.orig	Thu Oct 10 13:30:26 2002
+++ universal.c	Tue Dec 10 18:47:31 2002
@@ -338,8 +338,8 @@ XS(XS_UNIVERSAL_VERSION)
 	    req = new_version(req);
 
 	if ( vcmp( SvRV(req), SvRV(sv) ) > 0 )
-	    Perl_croak(aTHX_ "%s version %s required--this is only version %s",
-		HvNAME(pkg), SvPV(req,PL_na), SvPV(sv,PL_na));
+	    Perl_croak(aTHX_ "%s version %_ required--this is only version %_",
+		HvNAME(pkg), req, sv);
     }
 
     ST(0) = sv;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About