Bug 51458 - sign extension may cause error in BitField
Summary: sign extension may cause error in BitField
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.8-dev
Hardware: All All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-01 09:54 UTC by jingqi
Modified: 2011-07-01 16:29 UTC (History)
0 users



Attachments
use cycle right shifting instead of just right shifting (403 bytes, patch)
2011-07-01 09:54 UTC, jingqi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jingqi 2011-07-01 09:54:57 UTC
Created attachment 27233 [details]
use cycle right shifting instead of just right shifting

the following junit test will fail,

final BitField bf1 = new BitField(0xF), bf2 = new BitField(0xF0000000);
int a = 0;
a = bf1.setValue(a, 9);
a = bf2.setValue(a, 9);
assertEquals(9, bf1.getValue(a));
assertEquals(9, bf2.getValue(a)); // fails, actually get -7

this bug haven't affected POI, just may cause error in future
Comment 1 Nick Burch 2011-07-01 16:29:26 UTC
Thanks for spotting this, patch applied (along with your unit test) in r1141977.