This is the mail archive of the gcc-patches@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]

Re: RFC/RFHelp: c-decl.c rewrite - almost but not quite


On Mar 16, 2004, at 4:29 PM, Joseph S. Myers wrote:
On Tue, 16 Mar 2004, Dale Johannesen wrote:
Indeed, gcc doesn't even warn about this:

int f() {return 0;}
int h() {return f(5);}

That's going a bit far, don't you think? It's undefined behavior.

Undefined at runtime, if h is ever called, rather than undefined at
compile time, permitting an error. Remember that in the C standard all
function calls are described as being calls through function pointers (the
function name f being converted to pointer to function), so the call is
through a pointer to function without parameter type information.

How do you make that out? Here's the language:


If the expression that denotes the called function has a type that does not include a prototype,
the integer promotions are performed on each argument, and arguments that have type float
are promoted todouble. These are called the default argument promotions. If the number of
arguments does not equal the number of parameters, the behavior is undefined.


I don't see anything about run time vs compile time there.


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