#94 Replace AND with cast causes data loss

closed-fixed
nobody
None
5
2013-05-25
2001-07-21
No

Originally part of bug #408972.

In the code
int leftShiftIntMasked3 (int v) {
return ((v & 0xff) << 3);
}

(part of support/regression/bug-408972.c), v is cast
to a char instead of being anded. This char is then
shifted left by 3, causing the top three bits to be
dropped. The result is then cast up for the return.

Discussion

  • Michael Hope

    Michael Hope - 2001-07-21

    Logged In: YES
    user_id=373

    Also the code

    int leftShiftIntMasked2 (int v) {
    return ((v & 0xff) << 8);
    }

    produces a 'left shifting more than size of object changed
    to zero' warning. This warning is debatable.

     
  • Johan Knol

    Johan Knol - 2001-07-30

    Logged In: YES
    user_id=63512

    fixed in decorateType()

     
  • Johan Knol

    Johan Knol - 2001-07-30
    • labels: 101552 -->
    • milestone: --> fixed
    • status: open --> closed-fixed
     

Log in to post a comment.