I'm not sure what I am seeing here. The test results below are from an old PowerMac G5 running OS X 10.5.8. Its still around for testing under the big-endian PowerPC cpu. The compiler is GCC 5.4, and its provided by MacPorts.
The test program is below. Compiling it results in an error error: 'log2' is not a member of 'std'
.
$ cat test.cxx
#include <cmath>
int main(int argc, char* argv[])
{
double d = std::log2(2.3456789f);
return 0;
}
According to Is std::log2() an extension or C++ standard?, std::log2
should be available.
Why is the program failing to compile?
$ /opt/local/bin/g++-mp-5 --version
g++-mp-5 (MacPorts gcc5 5.4.0_0) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
$ /opt/local/bin/g++-mp-5 -std=c++11 test.cxx -o test.exe
test.cxx: In function 'int main(int, char**)':
test.cxx:4:16: error: 'log2' is not a member of 'std'
double d = std::log2(2.3456789f);
^
test.cxx:4:16: note: suggested alternative:
In file included from /usr/include/math.h:26:0,
from /opt/local/include/gcc5/c++/cmath:44,
from test.cxx:1:
/usr/include/architecture/ppc/math.h:431:15: note: 'log2'
extern double log2( double );
^
This may be related because of the old hardware: C++11 cmath functions not in std namespace for android NDK w/gcc-4.8 or clang 3.4. I realize Android is a different platform.
Now open in the MacPorts issue tracker: Issue 53226: PowerMac, GCC 5.4 and "error: 'std::log2' has not been declared".
Now open in the GCC issue tracker: Issue 79017: Old PowerMac G5, MacPorts GCC 5.4, C++11 and "std::log2 has not been declared"
The GCC report at Issue 79017: Old PowerMac G5, MacPorts GCC 5.4, C++11 and "std::log2 has not been declared" got some good comments from the GCC devs.
According to Jonathan Wakely and the results of the program below: