Subject: bug#43579: g++ does not provide std::fegetround

From: Andreas Enge <[email-masked]>
Date: Wed, 23 Sep 2020 18:21:21 +0200

Hello,

this report is related to
   https://github.com/fplll/fplll/issues/444

The following test file round.cpp does not compile with our g++-10.2.0:
#include <cfenv>
int main () {
   return std::fegetround ();
}

Compilation (also when adding "--std=c++11") prints the error:
round.cpp: In function 'int main()':
round.cpp:4:16: error: 'fegetround' is not a member of 'std'; did you mean 'fegetround'?
    4 |    return std::fegetround ();
      |                ^~~~~~~~~~
In file included from /home/andreas/.guix-profile/include/c++/fenv.h:36,
                 from /home/andreas/.guix-profile/include/c++/cfenv:41,
                 from round.cpp:1:
/home/andreas/.guix-profile/include/fenv.h:104:12: note: 'fegetround' declared here
  104 | extern int fegetround (void) __THROW __attribute_pure__;
      |            ^~~~~~~~~~

Compilation succeeds when replacing std::fegetround by fegetround; however,
the former is supposedly part of the C++11 standard.

The culprit is apparently cfenv, which contains the following:
#if _GLIBCXX_HAVE_FENV_H
#include_next <fenv.h>
#endif
#if _GLIBCXX_USE_C99_FENV_TR1
...
#undef fegetround
...
namespace std
{
...
using ::fegetround;
...
}

Our include/c++/x86_64-unknown-linux-gnu/bits/c++config.h has this:
#define _GLIBCXX_HAVE_FENV_H 1
/* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in
namespace std::tr1. */
/* #undef _GLIBCXX_USE_C99_FENV_TR1 */
whereas apparently on other distributions (opensuse, for instance),
_GLIBCXX_USE_C99_FENV_TR1 is defined and leads to std::fesetround being
defined.

And when I look at the build log
   https://ci.guix.gnu.org/log/xpdy9vvqym9xv7praqkwsm3gdzn2kv1p-gcc-10.2.0
for instance, there are the following lines:
checking for ISO C99 support to TR1 in <fenv.h>... no
checking for ISO C99 support to TR1 in <stdint.h>... yes
checking for ISO C99 support to TR1 in <math.h>... yes
checking for ISO C99 support to TR1 in <inttypes.h>... yes
whereas in opensuse, there is
checking for ISO C99 support to TR1 in <fenv.h>... yes

Now it would be interesting to have a look at config.log for gcc...

Andreas