[llvm-bugs] [Bug 35268] New: System header warning in /usr/include/math.h

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 9 13:32:23 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35268

            Bug ID: 35268
           Summary: System header warning in /usr/include/math.h
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tstellar at redhat.com
                CC: llvm-bugs at lists.llvm.org

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;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171109/c838acdc/attachment.html>


More information about the llvm-bugs mailing list