call of overloaded isnan(double&) is ambiguous

Viewed 196

I'm attempting to compile shapeit - https://github.com/odelaneau/shapeit4 The most recent gcc I have available is 5.3.1 When I run make, the following error trace is shown:

g++ -std=c++11 -O3 -mavx2 -mfma  -c src/main.cpp -o obj/main.o -Isrc -I/local/src/htslib-1.3.2/htslib -I/local/include/boost
In file included from src/phaser/phaser_header.h:29:0,
             from src/main.cpp:23:
src/models/haplotype_segment_single.h: In member function ‘bool 
haplotype_segment_single::TRANS_DIP_MULT()’:
src/models/haplotype_segment_single.h:556:25: error: call of overloaded ‘isnan(double&)’ is ambiguous
  return (isnan(sumDProbs) || isinf(sumDProbs) || sumDProbs < numeric_limits<double>::min());
                         ^
In file included from /usr/include/features.h:375:0,
                 from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/os_defines.h:39,
                 from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/x86_64-redhat-linux/bits/c++config.h:2255,
                 from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/bits/stl_algobase.h:59,
                 from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/vector:60,
                 from src/utils/otools.h:26,
                 from src/phaser/phaser_header.h:27,
                 from src/main.cpp:23:
/usr/include/bits/mathcalls.h:235:1: note: candidate: int isnan(double)
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 ^
In file included from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/random:38:0,
             from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/bits/stl_algo.h:66,
             from /opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/algorithm:62,
             from src/utils/otools.h:35,
             from src/phaser/phaser_header.h:27,
             from src/main.cpp:23:
/opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/cmath:634:3: note: candidate: constexpr bool std::isnan(long double)
   isnan(long double __x)
   ^
/opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/cmath:630:3: note: candidate: constexpr bool std::isnan(double)
   isnan(double __x)
   ^
/opt/rh/devtoolset-4/root/usr/include/c++/5.3.1/cmath:626:3: note: candidate: constexpr bool std::isnan(float)
   isnan(float __x)
   ^
In file included from src/phaser/phaser_header.h:29:0,
                 from src/main.cpp:23:

I attempted to replace the isnan(sumDProbs) call with std::isnan(sumDProbs) or with ::isnan(sumDProbs). Both of these finished compiling, but the resulting binary threw an Illegal Instruction. Is there a different namespace I should be using to clarify the isnan call?

This is el7 with the devtoolset-4 activated because el7 has gcc 4.8.5. I activate using scl enable devtoolset-4 -- bash and then run the compile commands.

I do not have a using namespace std; included.

This is the line that's throwing the ambiguous error: https://github.com/odelaneau/shapeit4/blob/master/src/models/haplotype_segment_single.h#L556

bool haplotype_segment_single::TRANS_HAP() {
sumHProbs = 0.0f;
unsigned int  curr_rel_segment_index = curr_segment_index-segment_first;
yt = M.getForwardTransProb(AlphaLocus[curr_rel_segment_index - 1], curr_abs_locus);
nt = 1.0f - yt;
//float fact1 = M.nt[curr_abs_locus-1] / AlphaSumSum[curr_rel_segment_index - 1];
float fact1 = nt / AlphaSumSum[curr_rel_segment_index - 1];
fill_n(HProbs, HAP_NUMBER*HAP_NUMBER, 0.0f);
for (int h1 = 0 ; h1 < HAP_NUMBER ; h1++) {
    //float fact2 = (AlphaSum[curr_rel_segment_index-1][h1]/AlphaSumSum[curr_rel_segment_index-1]) * M.t[curr_abs_locus - 1] / n_cond_haps;
    float fact2 = (AlphaSum[curr_rel_segment_index-1][h1]/AlphaSumSum[curr_rel_segment_index-1]) * yt / n_cond_haps;
    for (int k = 0 ; k < n_cond_haps ; k ++) {
        for (int h2 = 0 ; h2 < HAP_NUMBER ; h2++) HProbs[h1*HAP_NUMBER+h2]+=((Alpha[curr_rel_segment_index-1][k*HAP_NUMBER + h1]*fact1 + fact2)*prob[k*HAP_NUMBER+h2]);
    }
    sumHProbs += HProbs[h1*HAP_NUMBER+0]+HProbs[h1*HAP_NUMBER+1]+HProbs[h1*HAP_NUMBER+2]+HProbs[h1*HAP_NUMBER+3]+HProbs[h1*HAP_NUMBER+4]+HProbs[h1*HAP_NUMBER+5]+HProbs[h1*HAP_NUMBER+6]+HProbs[h1*HAP_NUMBER+7];
}
return (isnan(sumHProbs) || isinf(sumHProbs) || sumHProbs < numeric_limits<float>::min());
}

Do I need to change this line: return (isnan(sumHProbs) || isinf(sumHProbs) || sumHProbs < numeric_limits<float>::min());

to return (isnan((double)sumHProbs) || isinf(sumHProbs) || sumHProbs < numeric_limits<float>::min());

0 Answers
Related