This is the mail archive of the 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 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.

The manual lists diagnosing this sort of thing under "Certain Changes We
Don't Want to Make".  IMA means one of the reasons given there no longer
applies;  all calls in a whole program compiled at once could be checked
for consistency with an old-style definition and compiled into aborts with
a warning given if inconsistent.  (The most likely reason for it actually
to be worthwhile to implement this would be to avoid problems arising with
optimizations attempting to inline such calls, etc..)

Joseph S. Myers

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