include/cxx/{cstdlib,cmath}: Provide std::abs(float) overloads - #19891
include/cxx/{cstdlib,cmath}: Provide std::abs(float) overloads#19891mpflanzer wants to merge 1 commit into
Conversation
|
How shall I address the style errors in the |
8f1617f to
94f62fb
Compare
The overloads of std::abs are defined in cstdlib and cmath according to the C++ standard. Without these new definitions the `int std::abs(int)` function was selected for all argument types resulting in a truncation of the return values. Signed-off-by: Moritz Pflanzer <moritz@chickadee-engineering.com>
370d4da
94f62fb to
370d4da
Compare
That seems a bit of an issue. I think the underlying problem is that Nuttx still adds its own To avoid this situation without having to touch any of the include behavior I cannot include I now forward declare the I run the failing OOT test locally and it is now passing. My custom test is still behaving correctly with the new changes (same output as before). I also tested this one now with both settings of |
Summary
The new overloads of
std::absadded tocstdlibandcmathare defined as specified by the C++ standard: https://en.cppreference.com/cpp/numeric/math/fabsWithout these new definitions the
int std::abs(int)function, provided byusing ::abs, was selected for all argument types resulting in a truncation of the result.Impact
Improved compatibility with the C++ standard
Testing
Without the changes running this program results in the following output:
That is compliant for
::absbut not forstd::abs.With the changes the right overloads of
std::absare selected and the output is:Tested with the
qemu-armv7a:nshconfig