I am using GCC 10.2.0 from MSYS2 on Windows.
Recently I moved one C++ project from C++17 to C++20, and the problem with GLM library occurred.
Library:
1 2
https://github.com/g-truc/glm
GLM is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specifications.
Compiler output:
1 2 3
/glm/detail/type_half.inl:9:6: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]
9 | f *= f; // this will overflow before the for loop terminates
| ~~^~~~
Library function body:
1 2 3 4 5 6 7 8
GLM_FUNC_QUALIFIER float overflow()
{
volatilefloat f = 1e10;
for(int i = 0; i < 10; ++i)
f *= f; // this will overflow before the for loop terminates
return f;
}
Not sure what making it volatile does for you, except to force the machine to always load/store a float (thus washing away any improved accuracy by keeping the result in extended floating point format until the calculation is over).
The authors postulate that the library works with a wide range of compilers, perhaps this loop optimization is causing problems somewhere...
1 2 3 4 5 6 7 8
GCC 4.7 and higher
Intel C++ Compose XE 2013 and higher
Clang 3.4 and higher
Apple Clang 6.0 and higher
Visual C++ 2013 and higher
CUDA 9.0 and higher (experimental)
SYCL (experimental: only ComputeCpp implementation has been tested).
Any C++11 compiler