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

Re: Coverity finding: shift by negative

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
June 24, 2015 12:48
Subject:
Re: Coverity finding: shift by negative
Message ID:
CAJueppvS9w+tvq3KFUzMKEYTrYJ3QZUG84Ac8R3hoZk-U8ToNQ@mail.gmail.com
Allow me to attempt a summary of discussion so far.

- for the negative shifts, going the opposite direction makes the most sense
   - (if someone still wants the odd modulo thing, they can explicitly
do the modulo for the shift)

- for the "left overshift" the best option would be the one we cannot
take, that is, go bigint
  - since we cannot do the best, just going zero is the next best option

- for the "right overshift", going zero is the most natural (and
mirrors the above choice for "left overshift")

- for "use integer" we should treat the number as signed integer
  - if the integer is positive, the above policies (which are for
unsigned integers) work fine
  - if the integer is negative...
    - the "left overshift" should also zero
    - the "right overshift" should return -1 (as weird as it is)...
but there's a dilemma
      that currently the shifts cast to UV (undocumented, but most
probably some code
      somewhere would freak out if we started preserving the signedness)

- we should avoid annoying warnings if feasible

- we should avoid leaking wordsize (# of bits) if feasible

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