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

missing return value


The other day there was a request for a compile error if you do:

    int foo(void) { }

and the answer was "the standard says that this is legal -- after all,
you can say 'foo();' so the return value isn't used and it doesn't
matter that it's missing".

That makes sense.

So how about:

   int foo (void) { }
   ...
   j = foo ();

This clearly *is* wrong.  The compiler may not always be able to
tell.  If it can -- for example, if this is inlined code where the
function definition is available at the time the call is compiled --
it sure would be helpful to have an error message here.

I just helped a colleague track one of these down after he had already
spent a day or three looking.  Bugs like this can be hard to spot.
Especially if, as in this case, you were dealing with a class wrapped
around another class, and the wrappers all look the same, and those
wrappers are where the problem lies.

	 paul


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