These functions are gcc builtins. They are optimised away. On linux, too. (Compile with -save-temps to see what is produced, or check the disassembly with objdump -d.)

To do a proper test, use separate compilation units.

/* test_isnanl.c */ #include <math.h> int test_isnanl(long double x) { return isnanl(x); }
And link: cc main.o test_isnanl.o -lm && ./a.out || FAIL

However, the above is not entirely future-proof either—it's defeated with link-time optimisation (-flto).
So perhaps it would be better to
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(int argc, char *argv[]) { long double x = strtold(argv[1], NULL); printf("%d", isnanl(x)); printf("%Lf", erfl(x)); return 0; }

Finally, if you limit your scope to the usual gcc/clang, then there is the -fno-builtin option that will make your original test work as is. This might be the best option of all.


In reply to Re^3: [C Question] Determine if gcc provides erfl() function by Anonymous Monk
in thread [C Question] Determine if gcc provides erfl() function by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.