Please consider the following C++20 program:
void (*p)(int x);
void f(auto x) {
p = f;
}
int main() {
f(4.2);
}
Is this ill-formed? What I would have expected to happen is that f(4.2) instantiates f as void(double), and so the assignment of p to f should be a type mismatch. But, g++ accepts this without warning.
What am I missing?
Update
For reference, the following program:
void (*p)(int x);
void g(double x);
int main() {
p = g;
}
fails with error: invalid conversion from void (*)(double) to void (*)(int)