[Bug c/98945] New: gcc does not warn when assigning value of type int (*)() to variable of type int (*)(double)
rogi at skylittlesystem dot org
gcc-bugzilla@gcc.gnu.org
Tue Feb 2 23:24:42 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98945
Bug ID: 98945
Summary: gcc does not warn when assigning value of type int
(*)() to variable of type int (*)(double)
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rogi at skylittlesystem dot org
Target Milestone: ---
gcc complains about assigning a value of type `int (*)()` to a variable of type
`int (*)(float)`, but not for a variable of type `int (*)(double)`, which I
thought to be a minor bug.
First observed on version 9.3.0, and also after updating 10.2.1, both give the
same result.
Here's a small test case:
```
$ gcc -O0 -Wall -o a.out -xc - <<EOF
int f()
{
return 0;
}
int main()
{
int (*p_float)(float f) = f;
int (*p_double)(double d) = f;
return 0;
}
EOF
<stdin>: In function 'main':
<stdin>:8:35: warning: initialization of 'int (*)(float)' from incompatible
pointer type 'int (*)()' [-Wincompatible-pointer-types]
<stdin>:9:15: warning: unused variable 'p_double' [-Wunused-variable]
<stdin>:8:15: warning: unused variable 'p_float' [-Wunused-variable]
```
thanks <3
More information about the Gcc-bugs
mailing list