This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/83437] [8 Regression] bogus warning: cast between incompatible function types from ‘int (*)()’ to ‘V’ {aka ‘void* (*)()’ [-Wcast-function-type]
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 15 Dec 2017 18:27:26 +0000
- Subject: [Bug c++/83437] [8 Regression] bogus warning: cast between incompatible function types from ‘int (*)()’ to ‘V’ {aka ‘void* (*)()’ [-Wcast-function-type]
- Auto-submitted: auto-generated
- References: <bug-83437-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83437
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Bernd Edlinger from comment #5)
> I think the best solution would be to use "V = void (*)(void);"
>
> I quote from Joseph Myers e-mail from 10/10/2017 because I could not
> express it any better:
>
> "Sometimes an interface needs to store an arbitrary function type [...]
> That's the sort of thing libffi
> does - so it inherently needs to be able to take pointers to arbitrary
> function types, which thus need to be converted to a generic function
> type, and the de facto generic function pointer type in C is void (*)
> (void). (C11 6.11.6 says "The use of function declarators with empty
> parentheses (not prototype-format parameter type declarators) is an
> obsolescent feature.", so void (*) () is best avoided.) Likewise
> interfaces such as dlsym (which happens to return void * along with a
> special case in POSIX requiring conversions between void * and function
> pointers to work, but void (*) (void) is the natural type for such
> interfaces to use).
For C sure, but we are talking here about C++. void (*) () in C++ is different
from void (*) () in C.