[MOAB-dev] r1393 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Wed Nov 14 17:17:58 CST 2007
Author: kraftche
Date: 2007-11-14 17:17:58 -0600 (Wed, 14 Nov 2007)
New Revision: 1393
Modified:
MOAB/trunk/MBMeshSet.cpp
MOAB/trunk/MBMeshSet.hpp
Log:
Fix portability issue storing MBMeshSet parent/child lists (fixes bug on
Windows.) Apparently if a bit-field value is signed, gcc treats the bits
as the lower N bits of the declared type while Microsoft's compiler
consideres them to be a signed integer of N bits. Example:
struct S {
int bits : 2;
};
int n = 2;
S s;
s.bits = n;
n = s.bits;
s.bits has the binary value 10b. On Linux, n will finish with '2' while on
Windows it is '-1'. 10b can be either, depending on whether or
one considers it to be a unsigned value or a 2-bit 2s-compliment value.
Many thanks to Byron Hanks for disconvery this issue, helping to track down
the cause, and for testing the fix.
Modified: MOAB/trunk/MBMeshSet.cpp
===================================================================
--- MOAB/trunk/MBMeshSet.cpp 2007-11-14 22:13:16 UTC (rev 1392)
+++ MOAB/trunk/MBMeshSet.cpp 2007-11-14 23:17:58 UTC (rev 1393)
@@ -160,13 +160,13 @@
int MBMeshSet::add_parent( MBEntityHandle parent )
{
int result;
- mParentCount = insert_in_vector( mParentCount, parentMeshSets, parent, result );
+ mParentCount = insert_in_vector( (Count)mParentCount, parentMeshSets, parent, result );
return result;
}
int MBMeshSet::add_child( MBEntityHandle child )
{
int result;
- mChildCount = insert_in_vector( mChildCount, childMeshSets, child, result );
+ mChildCount = insert_in_vector( (Count)mChildCount, childMeshSets, child, result );
return result;
}
@@ -240,13 +240,13 @@
int MBMeshSet::remove_parent( MBEntityHandle parent )
{
int result;
- mParentCount = remove_from_vector( mParentCount, parentMeshSets, parent, result );
+ mParentCount = remove_from_vector( (Count)mParentCount, parentMeshSets, parent, result );
return result;
}
int MBMeshSet::remove_child( MBEntityHandle child )
{
int result;
- mChildCount = remove_from_vector( mChildCount, childMeshSets, child, result );
+ mChildCount = remove_from_vector( (Count)mChildCount, childMeshSets, child, result );
return result;
}
Modified: MOAB/trunk/MBMeshSet.hpp
===================================================================
--- MOAB/trunk/MBMeshSet.hpp 2007-11-14 22:13:16 UTC (rev 1392)
+++ MOAB/trunk/MBMeshSet.hpp 2007-11-14 23:17:58 UTC (rev 1393)
@@ -252,12 +252,12 @@
//! parentMeshSets.hnd. If MANY, then parentMeshSets.ptr contains
//! array begin and end pointers for a dynamically allocated array
//! of parent handles.
- Count mParentCount : 2;
+ unsigned mParentCount : 2;
//! If less than MANY, the number of children stored inline in
//! childMeshSets.hnd. If MANY, then childMeshSets.ptr contains
//! array begin and end pointers for a dynamically allocated array
//! of child handles.
- Count mChildCount : 2;
+ unsigned mChildCount : 2;
private:
//! Storage for parent and child lists
CompactList parentMeshSets, childMeshSets;
More information about the moab-dev
mailing list