Sample code:
#include <cmath>
auto x = std::sqrtf(1.0f);
Compilation command: g++ -std=c++17 foo.c
Gives error error: 'sqrtf' is not a member of 'std'
Version: g++.exe (Rev2, Built by MSYS2 project) 8.3.0
It works to use ::sqrtf
, and also works to use std::sqrt
(which chooses the correct overload). But the C++ Standard section [cmath.syn] requires that including <cmath>
makes std::sqrtf
available.
The same problem exists for std::sqrtl
, std::powf
, std::powl
, std::ceilf
and std::ceill
at least. (After spotting the problem with sqrtl I tried a few other functions and saw the same issues -- this is not an exhaustive list).
This is a bug in libstdc++ (it also exists on linux gcc), and not the runtime.
This issue has actually been known since 2017:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89279