Skip to content

in C double and _Float64 mist be destinct types (and float and _Float32) #50110

Closed
@llvmbot

Description

@llvmbot
Bugzilla Link 50766
Version 12.0
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillacinvalidResolved as invalid, i.e. not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions