develooper Front page | perl.perl5.porters | Postings from June 2015

Re: Coverity finding: shift by negative

Thread Previous | Thread Next
From:
Eirik Berg Hanssen
Date:
June 25, 2015 14:28
Subject:
Re: Coverity finding: shift by negative
Message ID:
CAHAeAG5fni2F9F0B+fe8Zh1sS53hrr1BVZq80NR5uEcYa+8KnQ@mail.gmail.com
On Thu, Jun 25, 2015 at 3:36 PM, Jarkko Hietaniemi <jhi@iki.fi> wrote:

> > For instance, I think "1 >> 32" should always be 0, and not 1 if
> > you have 32 bits integers, and 0 if you have 64.
>
> My plan is to implement the bare minimum of changes to avoid the nasal
> daemons.  Which means:
>
> (1) negative shift means the reverse shift
> (2) left shift or right shift by more than wordbits is zero


  Can we s/more than wordbits/wordbits or more/ that?  Sure, it would lose
backwards compatibility …

$ perl -E 'say 1>>$_ for 63..65;'
0
1
0
$

  … but that really _is_ backwards, no?


Eirik

Thread Previous | 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