GLM C++20 compilation warning

Good day! :3

I am not sure this is the place for reporting problems with third party libraries…
But since GLM is so commonly used and since I couldn’t find any way to report this to authors…

Actually the problem: recently I moved one C++ project from C++17 to C++20, and the problem with GLM occurred. That is compiler output:

/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
  |    ~~^~~~

Here is the library code whitch causes this:

GLM_FUNC_QUALIFIER float overflow()
	volatile float f = 1e10;

	for(int i = 0; i < 10; ++i)
		f *= f; // this will overflow before the for loop terminates
	return f;

Any ideas how to fix this temporarily (just for me)?
Or how to fix this “seriously” so it can be pull-requested to GLM repo?

It’s not clear what that function is supposed to do. However, the use of volatile appears to be intended to prevent compiler optimizations, rather than something reasonable.

What was deprecated is the use of computational assignment operators. So you could just change it to be f = f * f;, and presumably that would do whatever this function is supposed to be trying to do.

Or you can just turn off the warning for that deprecation.

1 Like

Thank you!
That f = f * f fix worked =)