Hello.
When I compile a C++ file that #includes <algorithm> (which I use for std::min() and std::max()), and I use the -fsingle-precision-constant CFLAG, I get lots of errors:
======== start output ==========
Compiling console.cpp:
In file included from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/random:51:0,
from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/stl_algo.h:66,
from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/algorithm:62,
from ../../../src/conio/console.cpp:30:
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/random.tcc: In member function 'void std::poisson_distribution<_IntType>::param_type::_M_initialize()':
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/random.tcc:1408:55: error: no matching function for call to 'max(float, const double&)'
_M_d = std::round(std::max(6.0, std::min(__m, __dx)));
^
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/random.tcc:1408:55: note: candidates are:
In file included from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/algorithm:61:0,
from ../../../src/conio/console.cpp:30:
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/stl_algobase.h:217:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
max(const _Tp& __a, const _Tp& __b)
^
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/stl_algobase.h:217:5: note: template argument deduction/substitution failed:
In file included from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/random:51:0,
from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/stl_algo.h:66,
from /opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/algorithm:62,
from ../../../src/conio/console.cpp:30:
/opt/launchpad/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include/c++/4.9.3/bits/random.tcc:1408:55: note: deduced conflicting types for parameter 'const _Tp' ('float' and 'double')
_M_d = std::round(std::max(6.0, std::min(__m, __dx)));
[etc]
======== end output ==========
When I remove the -fsingle-precision-constant, the errors go away. I presume the arm-none-eabi-g++ is not providing sufficient disambiguation (due to the conflating of floats and doubles) of the floats vs doubles in the template, and hence the errors.
Is this a bug? a feature of the STL that I will have to work around in the make file?
Is there a fix or an adjustment to the compiler that can be made?
Thank you,
Charles Miller