From:

Date:

June 23, 2015 00:03Subject:

Coverity finding: shift by negativeMessage ID:

5588A260.8070804@iki.fiCoverity flags the pp_left_shift and pp_right_shift in pp.c. Either of them can shift by a negative amount, called (ta-dah!) shift. The result of shifting by negative amount is the infamous undefined behavior territory (of the nasal demons kind). (As is shifting by more than the number of bits in the integer, but Coverity doesn't flag that. Yet.) Now, the question is, what should we do? What should we return? (Yes, I'm asking should we define a semantics for this thing which is undefined in C.) undef? shift left by negative n == shift right by -n ? shift right by negative n == shift left by -n? shift by too many bits == shift by n modulo wordbits? (with a sane definition of modulo for negative -n...) for use integer we would need to think about signed behavior. warn? (of "portable" kind?) croak? At the very minimum, I would suggest undef for the negative shift case. (To get Coverity off our case.)Thread Next

**Coverity finding: shift by negative**by Jarkko Hietaniemi- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Eric Brine
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Eirik Berg Hanssen
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by H.Merijn Brand
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Jan Dubois
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Rocco Caputo
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by David Cantrell
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Zefram
- Re: Coverity finding: shift by negative by H.Merijn Brand
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by ilmari
- Re: Coverity finding: shift by negative by Abigail
- Re: Coverity finding: shift by negative by Jan Dubois
- Re: Coverity finding: shift by negative by Paul "LeoNerd" Evans
- Re: Coverity finding: shift by negative by H.Merijn Brand
- Re: Coverity finding: shift by negative by Eirik Berg Hanssen
- Re: Coverity finding: shift by negative by Jan Dubois
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Eric Brine
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi
- Re: Coverity finding: shift by negative by Ricardo Signes
- Re: Coverity finding: shift by negative by Jarkko Hietaniemi

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About