plperl compiler warning

Started by Joe Conwayalmost 16 years ago8 messages
#1Joe Conway
mail@joeconway.com

Last night I noted the following warning:

plperl.c: In function ‘plperl_create_sub’:

plperl.c:1117: warning: null argument where non-null required (argument 2)

I'm not familiar enough with this code to propose a fix...

Joe

#2Tim Bunce
Tim.Bunce@pobox.com
In reply to: Joe Conway (#1)
Re: plperl compiler warning

On Thu, Jan 28, 2010 at 06:31:19AM -0800, Joe Conway wrote:

Last night I noted the following warning:

plperl.c: In function ‘plperl_create_sub’:

plperl.c:1117: warning: null argument where non-null required (argument 2)

The master branch of my git clone says line 1117 is:

subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));

Does that match yours? (If not, what is the text on the line?)

What perl version are you using?
What compiler version are you using?

Tim.

#3Joe Conway
mail@joeconway.com
In reply to: Tim Bunce (#2)
Re: plperl compiler warning

On 01/28/2010 07:30 AM, Tim Bunce wrote:

On Thu, Jan 28, 2010 at 06:31:19AM -0800, Joe Conway wrote:

Last night I noted the following warning:

plperl.c: In function ‘plperl_create_sub’:

plperl.c:1117: warning: null argument where non-null required (argument 2)

The master branch of my git clone says line 1117 is:

subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));

Does that match yours? (If not, what is the text on the line?)

I pull directly from CVS, not git, but in any case my line 1117 is

subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));

so it appears to be the same

What perl version are you using?
What compiler version are you using?

I'm on stock Fedora 12:

perl.x86_64 4:5.10.0-87.fc12
gcc.x86_64 4.4.2-20.fc12

HTH,

Joe

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#3)
Re: plperl compiler warning

Joe Conway <mail@joeconway.com> writes:

I pull directly from CVS, not git, but in any case my line 1117 is
subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));
so it appears to be the same

What perl version are you using?
What compiler version are you using?

I'm on stock Fedora 12:

I see the same on Fedora 11. The -E expansion of the line in question is

subref = Perl_newRV(((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))), (SV*)((((GV*)sub_glob)->sv_u.svu_gp)->gp_cvgen ? ((void *)0) : (((GV*)sub_glob)->sv_u.svu_gp)->gp_cv));

so it's evidently unhappy about the fact that GvCVu can return null,
while Perl_newRV is declared __attribute__((nonnull(2))).

It looks to me like this is probably a live bug not just compiler
hypersensitivity.

regards, tom lane

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#4)
Re: plperl compiler warning

Tom Lane wrote:

Joe Conway <mail@joeconway.com> writes:

I pull directly from CVS, not git, but in any case my line 1117 is
subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));
so it appears to be the same

What perl version are you using?
What compiler version are you using?

I'm on stock Fedora 12:

I see the same on Fedora 11. The -E expansion of the line in question is

subref = Perl_newRV(((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))), (SV*)((((GV*)sub_glob)->sv_u.svu_gp)->gp_cvgen ? ((void *)0) : (((GV*)sub_glob)->sv_u.svu_gp)->gp_cv));

so it's evidently unhappy about the fact that GvCVu can return null,
while Perl_newRV is declared __attribute__((nonnull(2))).

It looks to me like this is probably a live bug not just compiler
hypersensitivity.

It's on my F11 box too ... I guess it's time to upgrade my work machine,
doesn't get reported by my usual setup.

Tim, any suggestions?

cheers

andrew

#6Tim Bunce
Tim.Bunce@pobox.com
In reply to: Tom Lane (#4)
1 attachment(s)
Re: plperl compiler warning

On Thu, Jan 28, 2010 at 12:49:20PM -0500, Tom Lane wrote:

Joe Conway <mail@joeconway.com> writes:

I pull directly from CVS, not git, but in any case my line 1117 is
subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));
so it appears to be the same

What perl version are you using?
What compiler version are you using?

I'm on stock Fedora 12:

I see the same on Fedora 11. The -E expansion of the line in question is

subref = Perl_newRV(((PerlInterpreter *)pthread_getspecific((*Perl_Gthr_key_ptr(((void *)0))))), (SV*)((((GV*)sub_glob)->sv_u.svu_gp)->gp_cvgen ? ((void *)0) : (((GV*)sub_glob)->sv_u.svu_gp)->gp_cv));

so it's evidently unhappy about the fact that GvCVu can return null,
while Perl_newRV is declared __attribute__((nonnull(2))).

It looks to me like this is probably a live bug not just compiler
hypersensitivity.

Yes. (ISTR there have been cases where the notnull attribute was
misapplied to some perl functions, but that's not the case here.)

I think I missed this because the Xcode compiler on Snow Leopard is
fairly old (gcc 4.2.1).

Patch attached.

Tim.

Attachments:

plperl-fix-GvCVu-warn.patchtext/x-patch; charset=us-asciiDownload
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 9277072..2dd3458 100644
*** a/src/pl/plperl/plperl.c
--- b/src/pl/plperl/plperl.c
*************** plperl_create_sub(plperl_proc_desc *prod
*** 1113,1120 ****
  
  	if (count == 1) {
  		GV *sub_glob = (GV*)POPs;
! 		if (sub_glob && SvTYPE(sub_glob) == SVt_PVGV)
! 			subref = newRV_inc((SV*)GvCVu((GV*)sub_glob));
  	}
  
  	PUTBACK;
--- 1113,1123 ----
  
  	if (count == 1) {
  		GV *sub_glob = (GV*)POPs;
! 		if (sub_glob && SvTYPE(sub_glob) == SVt_PVGV) {
! 			SV *sv = (SV*)GvCVu((GV*)sub_glob);
! 			if (sv)
! 				subref = newRV_inc(sv);
! 		}
  	}
  
  	PUTBACK;
#7Andrew Dunstan
andrew@dunslane.net
In reply to: Tim Bunce (#6)
Re: plperl compiler warning

Tim Bunce wrote:

It looks to me like this is probably a live bug not just compiler
hypersensitivity.

Yes. (ISTR there have been cases where the notnull attribute was
misapplied to some perl functions, but that's not the case here.)

I think I missed this because the Xcode compiler on Snow Leopard is
fairly old (gcc 4.2.1).

Patch attached.

Thanks. Applied.

cheers

andrew

#8Tim Bunce
Tim.Bunce@pobox.com
In reply to: Tim Bunce (#6)
Re: plperl compiler warning

On Thu, Jan 28, 2010 at 07:49:37PM +0000, Tim Bunce wrote:

I think I missed this because the Xcode compiler on Snow Leopard is
fairly old (gcc 4.2.1).

For the record, gcc 4.2.1 does report the error. I'd missed it because
I'd done most of my builds with perl 5.8.x and the notnull attributes was
added later, in 5.10.0.

Tim.