[llvm-bugs] [Bug 26283] New: float.h is missing mandatory C11 fp macros like DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jan 24 16:00:24 PST 2016


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

            Bug ID: 26283
           Summary: float.h is missing mandatory C11 fp macros like
                    DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
          Assignee: unassignedclangbugs at nondot.org
          Reporter: j.lopes.teixeira at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150209/123212.html

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

-- 
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/20160125/238843e5/attachment.html>


More information about the llvm-bugs mailing list