public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>
To: joel@rtems.org, Newlib <newlib@sourceware.org>
Subject: Re: round() on arm vs aarch64
Date: Mon, 7 Nov 2022 17:28:36 +0000	[thread overview]
Message-ID: <b25e7c5a-0df0-ed38-881d-98d272b85d65@foss.arm.com> (raw)
In-Reply-To: <CAF9ehCU6TcXBu1QVGaotssV-RxWKsZ6nT2X2iZGtBRa0qqFBOQ@mail.gmail.com>



On 03/11/2022 14:13, Joel Sherrill wrote:
> 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

Have you tried comparing the pre-processed output from the two versions? 
  It might give a clue as to what's going on.

R.

  reply	other threads:[~2022-11-07 17:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 14:13 Joel Sherrill
2022-11-07 17:28 ` Richard Earnshaw [this message]
2022-11-15 15:38   ` Joel Sherrill
2022-11-15 15:58     ` Stephanos Ioannidis
2022-11-15 18:17       ` Joel Sherrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b25e7c5a-0df0-ed38-881d-98d272b85d65@foss.arm.com \
    --to=richard.earnshaw@foss.arm.com \
    --cc=joel@rtems.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).