[patch] Fix `return' of long/long-long results with no debuginfo

Mark Kettenis mark.kettenis@xs4all.nl
Wed Feb 11 21:23:00 GMT 2009


> Date: Wed, 11 Feb 2009 15:50:45 -0500
> From: Daniel Jacobowitz <drow@false.org>
> 
> On Wed, Feb 11, 2009 at 09:40:00PM +0100, Mark Kettenis wrote:
> > Sorry, this is wrong.  Functions without return type implicitly return int.
> 
> I think it's a mistake to bring this rule (from K&R C, and removed in
> C99) to GDB.  This is a different context; it's not functions declared
> without a return type in source code, but functions with an unknown
> return type (and unknown source language).

I disagree.  I think it is the behaviour that makes the most sense in
a historical context.  And I have a (somewhat) vague recollection that
there are debug formats or compilers where we cant distinguish between
functions without a return type and functions with "unknown" return
type.

> Everything we pick will be wrong some of the time, but IMO "long" is
> maximally useful.  "long long" on 32-bit platforms is going to pick
> up garbage from the next register for int or void * returns.  Most
> platforms with int != long will have the return register with
> sizeof(long).

The right solution of course is to distribute libraries with debug
sumbols.  But in cases where that is impossible, would it be an idea
to use the type of the return value expression given by the user
instead of int as a fallback?

In the case at hand, "return -1" will still fail, but it would be
possible to do return (void *)-1 to do what the user wanted.



More information about the Gdb-patches mailing list