<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 --- - float.h is missing mandatory C11 fp macros like DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG"
   href="https://llvm.org/bugs/show_bug.cgi?id=26283">26283</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>float.h is missing mandatory C11 fp macros like DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>j.lopes.teixeira@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi, using Clang 3.8 from the Ubuntu ppa I found that float.h does not define
some mandatory C11 floating point constants (as per N1570 draft: 5.2.4.2.2p11).

Steps to reproduce: run this simple diagnostic snippet, where Clang fails with
"error: use of undeclared identifier 'LDBL_DECIMAL_DIG'", despite the proper
include.

#include <stdio.h>
#include <float.h>
int main(void) {
long double x=0.3L;
printf("v=%s; x=%.*Lg\n",__VERSION__,LDBL_DECIMAL_DIG,x);
return 0;}

Expected: the value is to be printed with the right decimal places, as defined
by the C11 spec.

I have checked that at least DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG are not
defined on /usr/lib/llvm-3.8/lib/clang/3.8.0/include/float.h, but internal
versions with underscores (like __LDBL_DECIMAL_DIG__) seem to exist elsewhere,
but are not exposed in a standard compliant way. I can't say if the underscored
versions are "correct" in that they evaluate to the proper value for all target
architectures.

All versions of Clang ought to be affected, but only 3.6 and 3.8 were tested. A
possibly (vaguely) relevant mailing list post exists:
<a href="http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150209/123212.html">http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150209/123212.html</a>

GCC/glibc work correctly as expected since at least 4.8.4, but possibly sooner.

No other fp macros were tested, but the above ML post suggests that build tests
that check for them are not universally available, so more macros might be
missing.

Output of: clang-3.8 --version
Ubuntu clang version 3.8.0-svn257311-1~exp1 (trunk) (based on LLVM 3.8.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin</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>