[Bug c++/82594] Please provide better parameter / argument mismatch warnings/notes
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 17 22:33:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82594
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-10-17
Version|unknown |7.2.0
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So if there are more than one overloads, the C++ front-end produces:
t88.c: In function 'void initialize()':
t88.c:13:35: error: no matching function for call to 'set_delete_thread(void
(&)(S2*))'
set_delete_thread (delete_thread);
^
t88.c:5:6: note: candidate: void set_delete_thread(S1*, void (*)(S2*))
void set_delete_thread (struct S1 *, void (*) (struct S2 *));
^~~~~~~~~~~~~~~~~
t88.c:5:6: note: candidate expects 2 arguments, 1 provided
t88.c:6:6: note: candidate: void set_delete_thread(S1*)
void set_delete_thread (struct S1 *);
^~~~~~~~~~~~~~~~~
t88.c:6:6: note: no known conversion for argument 1 from 'void(S2*)' to 'S1*'
But with only one overload, GCC produces:
t88.c: In function 'void initialize()':
t88.c:13:35: error: cannot convert 'void (*)(S2*)' to 'S1*' for argument '1' to
'void set_delete_thread(S1*, void (*)(S2*))'
set_delete_thread (delete_thread);
^
I do think the C++ front-end's case with one overload set is actually can be
improved.
Note the C front-end produces:
t88.c: In function 'initialize':
t88.c:13:22: warning: passing argument 1 of 'set_delete_thread' from
incompatible pointer type [-Wincompatible-pointer-types]
set_delete_thread (delete_thread);
^~~~~~~~~~~~~
t88.c:5:6: note: expected 'struct S1 *' but argument is of type 'void
(*)(struct S2 *)'
void set_delete_thread (struct S1 *, void (*) (struct S2 *));
^~~~~~~~~~~~~~~~~
t88.c:13:3: error: too few arguments to function 'set_delete_thread'
set_delete_thread (delete_thread);
^~~~~~~~~~~~~~~~~
t88.c:5:6: note: declared here
void set_delete_thread (struct S1 *, void (*) (struct S2 *));
^~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list