Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -Wshift-negative-value error #68

Open
henrybaxter opened this issue Aug 31, 2016 · 3 comments
Open

Fix -Wshift-negative-value error #68

henrybaxter opened this issue Aug 31, 2016 · 3 comments

Comments

@henrybaxter
Copy link

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).

@pacifire
Copy link

pacifire commented Jan 16, 2017

@henrybaxter : Thanks Man it worked.

@pacifire
Copy link

@henrybaxter : Could you please help me with this : #70

@subatomicglue
Copy link

subatomicglue commented Jan 16, 2018

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants