https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116871

            Bug ID: 116871
           Summary: -Wincompatible-pointer-types for function pointers
                    could highlight the mismatch better
           Product: gcc
           Version: 13.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

See https://godbolt.org/z/zavE7ePf9.

For the following:
```
void f(int a);

int main() {
    void (*g) (float b) = &f;
}
```

With Clang, we get:
```
<source>:4:12: error: incompatible function pointer types initializing 'void
(*)(float)' with an expression of type 'void (*)(int)'
[-Wincompatible-function-pointer-types]
    4 |     void (*g) (float b) = &f;
      |            ^              ~~
1 error generated.
Compiler returned: 1
```

But with GCC, we get:
```
<source>: In function 'main':
<source>:4:27: error: initialization of 'void (*)(float)' from incompatible
pointer type 'void (*)(int)' [-Wincompatible-pointer-types]
    4 |     void (*g) (float b) = &f;
      |                           ^
Compiler returned: 1
```

i.e. clang underlines the LHS as well as the RHS. It's trivial but w/e.

Reply via email to