std::isnan and isnan visibility problems

Bug #1617838 reported by Steve Lorimer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-5 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Consider the following small test application:

#include <iostream>
#include <cmath>
#include <math.h>

int main()
{
    double d = NAN;

    std::cout << std::isnan(d) << '\n';
    std::cout << isnan(d) << '\n';

    return 0;
}
Compiling on Ubuntu 16.04 with g++-5.4.0 using C++11 standard fails:

$ g++ -std=c++11 main.cpp
main.cpp: In function ‘int main()’:
main.cpp:10:25: error: ‘isnan’ was not declared in this scope
     std::cout << isnan(d) << '\n';
                         ^
main.cpp:10:25: note: suggested alternative:
In file included from main.cpp:3:0:
/usr/include/c++/5/cmath:641:5: note: ‘std::isnan’
     isnan(_Tp __x)
     ^

I've compiled this on Centos gcc-4.9.1 and gcc-5.2.1 and it works on both.
I've compiled this on Ubuntu gcc-4.9.3 and that too works.
However, compiling on Ununtu gcc-5.4.0 doesn't.

I've also tried several online compilers, with mixed results.

Wandbox has gcc-6.3.0, gcc-5.2.0, gcc-5.1.0 and they all compiled fine.
Godbolt broke for gcc-4.9.2 through gcc-5.3, but then works on 6.1.

Given it works for gcc-5.2.0 on Wandbox and breaks for gcc-5-2.0 on Godbolt makes me thing one must be using a patched standard library.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.