<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Clang should communicate it's support for annex F (IEC 60559 / IEEE-754) to glibc"
   href="https://llvm.org/bugs/show_bug.cgi?id=31653">31653</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang should communicate it's support for annex F (IEC 60559 / IEEE-754) to glibc
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Headers
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dan@su-root.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>andrew.kaylor@intel.com, david.l.kreitzer@intel.com, hfinkel@anl.gov, llvm-bugs@lists.llvm.org, scanon@apple.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>It seems with Clang (3.9) on Linux with glibc 2.24 that the `__STDC_IEC_559__`
macro is defined by glibc itself by `/usr/include/stdc-predef.h` (gets included
by clang if a glibc header gets included like `stdio.h`).

that code does

```
/* glibc's intent is to support the IEC 559 math functionality, real
   and complex.  If the GCC (4.9 and later) predefined macros
   specifying compiler intent are available, use them to determine
   whether the overall intent is to support these features; otherwise,
   presume an older compiler has intent to support these features and
   define these macros by default.  */

#ifdef __GCC_IEC_559
# if __GCC_IEC_559 > 0
#  define __STDC_IEC_559__ 1
# endif
#else
# define __STDC_IEC_559__ 1
#endif
```

Clang doesn't define `_GCC_IEC_559` so glibc defines `__STDC_IEC_559__ ` to be
`1` regardless of whether or not Clang supports it (does it?
<a href="https://llvm.org/bugs/show_bug.cgi?format=multiple&id=17000">https://llvm.org/bugs/show_bug.cgi?format=multiple&id=17000</a> suggests that Clang
doesn't).

This doesn't seem to be desirable. You can see above how glibc checks the
`_GCC_IEC_559` macro from gcc to test whether or gcc intends to support annex
F. I think we should do something similar to gcc so that Clang can control the
`__STDC_IEC_559__` macro when using glibc.

Depending on the implementation (i.e. whether or not we reuse the
`_GCC_IEC_559` macro) we choose we may need to speak to the glibc developers.

For context here are the gcc and glibc patches that landed a few years ago.

<a href="https://gcc.gnu.org/ml/gcc-patches/2013-10/msg01131.html">https://gcc.gnu.org/ml/gcc-patches/2013-10/msg01131.html</a>
<a href="https://sourceware.org/ml/libc-alpha/2013-10/msg00515.html">https://sourceware.org/ml/libc-alpha/2013-10/msg00515.html</a>

Those patches include good explanations of their motivation.</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>