develooper Front page | perl.perl5.porters | Postings from April 2017

Bad C code in ext/attributes/attributes.xs

Thread Next
From:
Karl Williamson
Date:
April 27, 2017 18:13
Subject:
Bad C code in ext/attributes/attributes.xs
Message ID:
eea45ed9-744c-4871-1aa5-43376ce4a81e@khwilliamson.com
This code is in attributes.xs starting at line 63
		    if (_memEQs(name, "lvalue")) {
			bool warn =
			    !CvISXSUB(MUTABLE_CV(sv))
			 && CvROOT(MUTABLE_CV(sv))
			 && !CvLVALUE(MUTABLE_CV(sv)) != negated;
			if (negated)
			    CvFLAGS(MUTABLE_CV(sv)) &= ~CVf_LVALUE;
			else
			    CvFLAGS(MUTABLE_CV(sv)) |= CVf_LVALUE;
			if (warn) break;
			continue;
		    }

The line
	&& !CvLVALUE(MUTABLE_CV(sv)) != negated;

is wrong because there are two '!' characters.  On gcc 6.3, the 
following warning is generated

attributes.xs:67:34: warning: logical not is only applied to the left 
hand side of comparison [-Wlogical-not-parentheses]

I'm guessing that the first '!' should be removed, but am unfamiliar 
with this area of the code, and what the consequences of it being the 
way it is might be.

Thread Next


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