round() on arm vs aarch64

Joel Sherrill joel@rtems.org
Thu Nov 3 14:13:12 GMT 2022


Hi

This is likely not a newlib bug but I thought I would start here because
I'm not sure what is going on and I thought someone on this list would have
an idea: This is a simple C++ function that calls std::round. It compiles
on arm but aarch64 says round isn't in the std namespace.

If you change the program to just use round() and not std::round() it
compiles on both architectures.

The compiler versions are the same and report:

arm-rtems6-gcc (GCC) 12.2.1 20221014 (RTEMS 6, RSB
cb8821e93378118e78a9cb25859789b126bd5761, Newlib 0b6342c)

=====================
$ cat r.cc
#include <cmath>



int wrap(double v)

{

  double r = std::round((float)v);

  return (r > 0);

}

[joel@devel round]$ arm-rtems6-gcc -Wall -c r.cc
[joel@devel round]$ aarch64-rtems6-gcc -Wall -c r.cc
r.cc: In function 'int wrap(double)':
r.cc:5:19: error: 'round' is not a member of 'std'; did you mean 'round'?
    5 |   double r = std::round((float)v);
      |                   ^~~~~
In file included from
/home/joel/rtems-work/tools/6/lib/gcc/aarch64-rtems6/12.2.1/include/c++/cmath:45,
                 from r.cc:1:
/home/joel/rtems-work/tools/6/aarch64-rtems6/include/math.h:337:15: note:
'round' declared here
  337 | extern double round (double);
=====================

Any ideas what would cause this?

Thanks

--joel


More information about the Newlib mailing list