07-24-2023, 01:25 AM
I have this piece of code:
```c
int foo() { return 0; }
int main()
{
int (*float_function)(float) = foo;
}
```
When compiled using `x86-64 GCC 12.2`, with `-Wall`, it produces the warning ([Link](
> warning: initialization of 'int (\*)(float)' from incompatible pointer type 'int (\*)()' [-Wincompatible-pointer-types]
But, when I change from `float` to `double` ([Link](
```c
int foo(){ return 0;}
int main()
{
int (*double_function)(double) = foo;
}
```
The warning is now gone.
But I think that both of these should get a warning.
Am I wrong somewhere? Why does GCC not complain about the second example?
```c
int foo() { return 0; }
int main()
{
int (*float_function)(float) = foo;
}
```
When compiled using `x86-64 GCC 12.2`, with `-Wall`, it produces the warning ([Link](
[To see links please register here]
)):> warning: initialization of 'int (\*)(float)' from incompatible pointer type 'int (\*)()' [-Wincompatible-pointer-types]
But, when I change from `float` to `double` ([Link](
[To see links please register here]
)):```c
int foo(){ return 0;}
int main()
{
int (*double_function)(double) = foo;
}
```
The warning is now gone.
But I think that both of these should get a warning.
Am I wrong somewhere? Why does GCC not complain about the second example?