BitSet: truncation in or_and

For "this |= set1 & set2" the result size
should be "max(this, min(set1, set2))" while
at present it is "min(set1, set2)" resulting
in truncation if the LHS is longer than the
RHS.
This commit is contained in:
Michael Davidsaver
2016-02-17 10:15:16 -05:00
parent 62893e33e9
commit d4292d81f2
2 changed files with 2 additions and 3 deletions

View File

@@ -279,7 +279,8 @@ namespace epics { namespace pvData {
uint32 inUse = (set1.wordsInUse < set2.wordsInUse) ? set1.wordsInUse : set2.wordsInUse;
ensureCapacity(inUse);
wordsInUse = inUse;
if(inUse>wordsInUse)
wordsInUse = inUse;
// Perform logical AND on words in common
for (uint32 i = 0; i < inUse; i++)

View File

@@ -152,9 +152,7 @@ static void testOperators()
b3.clear(); b3.set(1);
std::cout<<"# "<<toString(b3)<<" |= "<<toString(b1)<<" & "<<toString(b2)<<"\n";
b3.or_and(b1, b2);
testTodoBegin("Bug in or_and");
testOk(toString(b3) == "{1}", "%s == {1}", toString(b3).c_str());
testTodoEnd();
}