<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - System header warning in /usr/include/math.h"
   href="https://bugs.llvm.org/show_bug.cgi?id=35268">35268</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>System header warning in /usr/include/math.h
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>5.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tstellar@redhat.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>How to reproduce:

$ cat isnan.c 
#include <math.h>

int main(void)
{
  double foo = 1.0;

  if (isnan(foo))
    return 1;
  return 0;
}

$ clang -Wdouble-promotion -o isnan isnan.c
isnan.c:7:13: warning: implicit conversion increases floating-point precision:
'double' to 'long double' [-Wdouble-promotion]
  if (isnan(foo))
      ~~~~~~^~~~
/usr/include/math.h:644:46: note: expanded from macro 'isnan'
#  define isnan(x) __MATH_TG ((x), __isnan, (x))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:562:16: note: expanded from macro '__MATH_TG'
   : FUNC ## l ARGS)
     ~~~~~~~~~ ^~~~
1 warning generated.



This is an issue with glibc 2.25 and newer.  I spent some time debugging this
and it looks like in lib/Basic/DiagnosticIDs.cpp:471, the isInSystemHeader()
function is returning false, because the SourceLocation points to isnan.c:7. 
To make it more clear why there is a warning, here are the relevant parts of
the source after running the preprocessor:


extern int __isnan (double __value) __attribute__ ((__nothrow__ ))
__attribute__ ((__const__));
extern int __isnanf (float __value) __attribute__ ((__nothrow__ ))
__attribute__ ((__const__));
extern int __isnanl (long double __value) __attribute__ ((__nothrow__ ))
__attribute__ ((__const__));

int main(void)
{
  double foo = 1.0;

  if ((sizeof ((foo)) == sizeof (float) ? __isnanf (foo) : sizeof ((foo)) ==
sizeof (double) ? __isnan (foo) : __isnanl (foo)))
    return 1;
  return 0;
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>