Fix -Wshift-negative-value error
henrybaxter opened this issue · comments
Running run_tests.sh yielded
/Users/henry/liquidfun/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp:55:57: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
(-1 << xShift));
~~ ^
This can be fixed with
diff --git a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
index ce1c01e..dbc02c4 100644
--- a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
+++ b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
@@ -52,7 +52,7 @@ static const uint32 yMask = ((1u << yTruncBits) - 1u) << yShift;
static const uint32 xMask = ~yMask;
static const uint32 relativeTagRight = 1u << xShift;
static const uint32 relativeTagBottomLeft = (uint32)((1 << yShift) +
- (-1 << xShift));
+ -(1L << xShift));
static const uint32 relativeTagBottomRight = (1u << yShift) + (1u << xShift);
And then the unit tests complete without problem (yes the + - is unnecessary, but I thought it read the cleanest).
@henrybaxter : Thanks Man it worked.
@henrybaxter : Could you please help me with this : #70
Just ran into this with the stable tar.gz release also. The fix above worked, thank you!
https://github.com/google/liquidfun/releases liquidfun-1.1.0.tar.gz
on xcode 9.2
MacOSX 10.13.2
I additionally had to change the MacOSX SDK from 9 to 13 (latest).