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

Compilation warnings about abs() #484

Closed
kankaristo opened this issue Feb 21, 2016 · 3 comments
Closed

Compilation warnings about abs() #484

kankaristo opened this issue Feb 21, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@kankaristo
Copy link

I'm getting some compilation warnings from glm/detail/func_trigonometric.inl:

In file included from Debug/swig_glm_wrap.cxx:2805:
In file included from ../thirdparty/glm/glm.hpp:108:
In file included from ../thirdparty/glm/gtc/../trigonometric.hpp:32:
In file included from ../thirdparty/glm/detail/func_trigonometric.hpp:199:
../thirdparty/glm/detail/func_trigonometric.inl:209:92: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
                                                                                                         ^
Debug/swig_glm_wrap.cxx:106894:24: note: in instantiation of function template specialization 'glm::asinh<float>' requested here
  result = (float)glm::asinh((float const &)*arg1);
                       ^
../thirdparty/glm/detail/func_trigonometric.inl:209:92: note: use function 'std::abs' instead
                return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x));
                                                                                                         ^~~
                                                                                                         std::abs
../thirdparty/glm/detail/func_trigonometric.inl:239:6: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
                if(abs(x) >= genType(1))
                   ^
Debug/swig_glm_wrap.cxx:107236:24: note: in instantiation of function template specialization 'glm::atanh<float>' requested here
  result = (float)glm::atanh((float const &)*arg1);
                       ^
../thirdparty/glm/detail/func_trigonometric.inl:239:6: note: use function 'std::abs' instead
                if(abs(x) >= genType(1))
                   ^~~
                   std::abs
2 warnings generated.

The above warnings are from Clang on OS X, but I think I remember seeing them on some other platform as well.

Like the warning message suggests, changing abs(x) to std::abs(x) seems to fix this.

@Groovounet Groovounet added the bug label Feb 21, 2016
@Groovounet Groovounet added this to the GLM 0.9.7 milestone Feb 21, 2016
@Groovounet Groovounet self-assigned this Feb 21, 2016
@Groovounet
Copy link
Member

Hi,

I applied your proposed fix on both 0.9.7 and master branches.

Thanks for reporting!
Christophe

@kankaristo
Copy link
Author

Thanks, that was fast!

There was a second warning in the same file for atanh() (line 239).

Groovounet added a commit that referenced this issue Feb 21, 2016
@Groovounet
Copy link
Member

Fixed! :)

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

No branches or pull requests

2 participants