This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA] [PATCH] Add a warning for invalid function casts
On Thu, 5 Oct 2017, Bernd Edlinger wrote:
> But why is int(*)(int) compatible to (int)(*)() but not
> to int(*)(int,...) ?
I think it's a matter of what function types were possible in K&R C.
<stdarg.h> variadic types weren't (there was an older <varargs.h>), and
neither were types with arguments of type float or narrower-than-int
integers (because those always got promoted to a wider type when passed as
function arguments to an unprototyped function). And those types that
were impossible in K&R C always require function prototypes. (The
possibility of function types without a prototype is a legacy feature.
There was some suggestion of removing it for C11, but no-one ever produced
a paper for WG14 proposing the actual wording changes that would have been
needed.)
--
Joseph S. Myers
joseph@codesourcery.com