This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/83437] [8 Regression] bogus warning: cast between incompatible function types from ‘int (*)()’ to ‘V’ {aka ‘void* (*)()’ [-Wcast-function-type]


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]