http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46076
--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> 2010-11-18 11:31:59 UTC --- On Wed, 17 Nov 2010, matt at use dot net wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46076 > > --- Comment #11 from Matt Hargett <matt at use dot net> 2010-11-17 21:37:43 > UTC --- > Given that "int foo()" and "int foo(void)" are not varargs functions, > shouldn't > GCC mainline be able to optimize this? The types are not treated as compatible. The following would change that: Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 166900) +++ tree-ssa.c (working copy) @@ -1410,6 +1410,11 @@ useless_type_conversion_p (tree outer_ty if (!TYPE_ARG_TYPES (outer_type)) return true; + /* A conversion between unprototyped and empty argument list is ok. */ + if (TYPE_ARG_TYPES (outer_type) == void_list_node + && !TYPE_ARG_TYPES (inner_type)) + return true; + /* If the unqualified argument types are compatible the conversion is useless. */ if (TYPE_ARG_TYPES (outer_type) == TYPE_ARG_TYPES (inner_type)) But for example our type-generic builtins for isinf and friends also use a NULL TYPE_ARG_TYPES list but they _are_ variadic and certainly not compatible with isinf (void). I'm also not sure if other languages allow variadic functions without a first arg (the backends would certainly handle that just fine I think). That said - the middle-end doesn't really have a notion of "unprototyped". That's a concept the frontend should lower (at call-sites, but that requires some middle-end infrastructure change). Richard.