Bug 60407 - [C++11] call of overloaded ‘isnan’ is ambiguous
Summary: [C++11] call of overloaded ‘isnan’ is ambiguous
Status: RESOLVED DUPLICATE of bug 48891
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://gist.githubusercontent.com/di...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-04 09:31 UTC by Dilawar Singh
Modified: 2016-01-07 13:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-03-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dilawar Singh 2014-03-04 09:31:30 UTC
In a large project, I get the following trace. This, however, compiled with g++4.7.x. Flag -std=c++11 is enabled in both cases.


ksolve/RateTerm.h:402:29: note: candidates are:
In file included from /usr/include/features.h:371:0,
                 from /usr/include/math.h:27,
<deleted lines>
/usr/include/i386-linux-gnu/bits/mathcalls.h:235:1: note: int isnan(double)
 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 ^
In file included from /usr/include/c++/4.8/random:38:0,
                 from /usr/include/c++/4.8/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8/algorithm:62,
<deleted lines>
/usr/include/c++/4.8/cmath:626:3: note: constexpr bool std::isnan(long double)
   isnan(long double __x)
Comment 1 Andrew Pinski 2014-03-04 09:35:57 UTC
This sounds like you are including math.h and then later on cmath.  I don't know if this is a valid thing to do.
Comment 2 Andrew Pinski 2014-03-04 09:38:03 UTC
But I cannot reproduce it with what I thought it was, please provide the preprocessed source.
Comment 3 Jonathan Wakely 2014-03-04 09:39:16 UTC
It's perfectly valid to do that.

Without a testcase we can't do anything, please read http://gcc.gnu.org/bugs/
Comment 4 Dilawar Singh 2014-03-04 10:22:36 UTC
g++ info can be found here 

http://pastebin.com/raw.php?i=dA05h3ku
Comment 5 Dilawar Singh 2014-03-04 10:23:51 UTC
Hi,

Added the *.ii file and g++ -v output. Since one file was large, links are given.


(In reply to Dilawar Singh from comment #4)
> g++ info can be found here 
> 
> http://pastebin.com/raw.php?i=dA05h3ku
Comment 6 Tobias Burnus 2014-03-04 11:06:17 UTC
(In reply to Dilawar Singh from comment #5)
> Added the *.ii file and g++ -v output. Since one file was large, links are
> given.
> > http://pastebin.com/raw.php?i=dA05h3ku


The g++ output I found at your pastebin link, however, I do not see the .ii file.
Comment 7 Jonathan Wakely 2014-03-04 11:12:50 UTC
(Tobias, see the URL field)

Reduced:

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

using namespace std;

int main()
{
  double d = 1.0;
  return isnan(d);
}


isnan.cc: In function ‘int main()’:
isnan.cc:9:17: error: call of overloaded ‘isnan(double&)’ is ambiguous
   return isnan(d);
                 ^
isnan.cc:9:17: note: candidates are:
In file included from /usr/include/features.h:364:0,
                 from /usr/include/math.h:26,
                 from isnan.cc:1:
/usr/include/bits/mathcalls.h:234:1: note: int isnan(double)
 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 ^
In file included from isnan.cc:2:0:
/usr/include/c++/4.8.2/cmath:626:3: note: constexpr bool std::isnan(long double)
   isnan(long double __x)
   ^
/usr/include/c++/4.8.2/cmath:622:3: note: constexpr bool std::isnan(double)
   isnan(double __x)
   ^
/usr/include/c++/4.8.2/cmath:618:3: note: constexpr bool std::isnan(float)
   isnan(float __x)
   ^
Comment 8 Jonathan Wakely 2014-03-04 11:14:02 UTC
(In reply to Dilawar Singh from comment #0)
> In a large project, I get the following trace. This, however, compiled with
> g++4.7.x. Flag -std=c++11 is enabled in both cases.

Are you sure?

I get the same result with GCC 4.7.4, but only with -std=c++11
Comment 9 Dilawar Singh 2014-03-04 11:21:05 UTC
The snippet I sent you (in url filed) is a part of large project which compiles fine on Ubuntu-server (gcc4.7.x, I am not sure about x).

I will confirm it later once I login onto server again. Once I change `isnan` to `std::isnan` in my project, it compiles fine with my g++-4.8.1.
Comment 10 Marc Glisse 2014-03-04 13:37:45 UTC
Looks like a dup of PR 48891.
Comment 11 Marc Glisse 2014-03-04 20:34:36 UTC
> Looks like a dup of PR 48891.

See also the comments for PR 54130.
Comment 12 Dilawar Singh 2014-03-04 20:43:12 UTC
(In reply to Marc Glisse from comment #10)
> Looks like a dup of PR 48891.

Yes. It is very similar to this. Fine with me if it is marked dup.

I was mistaken about gcc version on server. It is default gcc comes with Ubuntu-Precice (gcc-4.6.3). Also -std=c++0x flag is not set with gcc-4.6.3. So in nutshell, compiles with gcc4.6.3 without -std=c++0x, but fails with gcc-4.8.0 with -std=c++0x. 

I mentioned -std=c++11 wrongly in first report.
Comment 13 Eugene Zelenko 2015-06-15 23:04:38 UTC
Same problem exists in 4.9.2.

In my code combining <cmath> with <vector> (later includes os_defines.h then features.h and mathcalls.h) produce same effect.
Comment 14 Jonathan Wakely 2016-01-07 13:16:39 UTC
Let's deal with this under 48891 then

*** This bug has been marked as a duplicate of bug 48891 ***