由于math.h
同时声明了int isnan(double x)
和int isnanf(float x)
,我预计下面的代码在与gcc -O0 -Wall -Wextra -Wpedantic -Wconversion -Wdouble-promotion
一起编译时会生成某种"Float to Double Promotion"警告.然而,事实并非如此.为何会是这样呢?
#include <stdio.h>
#include <math.h>
int main()
{
float x = 1.23f;
printf("%s\n", isnan(x) ? "nan" : "number");
return 0;
}