godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Warning: Using integer absolute value function 'abs'

Open aaronfranke opened this issue 2 years ago • 0 comments

I got these warnings when compiling with clang on Linux.

Automatically casting to integers here completely breaks this, so it should be fixed. I would open a PR, but I'm not sure if we should use suggested std::abs or a Godot-provided method.

https://github.com/godotengine/godot-cpp/blob/master/src/core/CameraMatrix.cpp#L564

godot-cpp/src/core/CameraMatrix.cpp:564:29: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                return Math::rad2deg(acos(abs(right_plane.normal.x))) * 2.0;
                                          ^
godot-cpp/src/core/CameraMatrix.cpp:564:29: note: use function 'std::abs' instead
                return Math::rad2deg(acos(abs(right_plane.normal.x))) * 2.0;
                                          ^~~
                                          std::abs
godot-cpp/src/core/CameraMatrix.cpp:573:29: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
                                          ^
godot-cpp/src/core/CameraMatrix.cpp:573:29: note: use function 'std::abs' instead
                return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
                                          ^~~
                                          std::abs
godot-cpp/src/core/CameraMatrix.cpp:573:77: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
                                                                                          ^
godot-cpp/src/core/CameraMatrix.cpp:573:77: note: use function 'std::abs' instead
                return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
                                                                                          ^~~
                                                                                          std::abs

aaronfranke avatar Jul 07 '21 02:07 aaronfranke