[llvm-bugs] [Bug 50766] New: in C double and _Float64 mist be destinct types (and float and _Float32)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 18 03:53:34 PDT 2021


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

            Bug ID: 50766
           Summary: in C double and _Float64 mist be destinct types (and
                    float and _Float32)
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaron_ng at inode.at
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

In C double and _Float64 are destinct types always.

In C float and _Float32 are destinct types always.

In _Float32 must NOT promote to double.

I have the definitive response from the sc22wg14 mailing list confirming
above statements.

Since the mailing list is not public I cannot sent the answer here.

x86-64 clang 12.0.0, icc 19.01 and tcc (unknown version) fail to compile
following program, but gcc 9.2.1 succeeds:


#include <stdio.h>
#include <math.h>

#define PGFN(name) _Generic((name), \
     float:   printf("%s():" #name "=%f\n",__func__,name),       \
     double:  printf("%s():" #name "=%f\n",__func__,name),       \
     default: printf("%s():" #name "=[unknown type]\n",__func__),\
     _Float32:printf("%s():" #name "=%f\n",__func__,((double)name)),       \
     _Float64:printf("%s():" #name "=%f\n",__func__,name)        \
     )

int main(int argc,char *argv[]){
     float f=4.0;
     double d=8.0;
     _Float32 f32=32.0;
     _Float64 f64=64.0;
     (void)argc,(void)argv;
     PGFN(f);
     PGFN(d);
     PGFN(f32);
     PGFN(f64);
     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/20210618/03ac109b/attachment.html>


More information about the llvm-bugs mailing list