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

Mark Kettenis
2009-02-11T22:44:53Z

> Date: Wed, 11 Feb 2009 22:46:47 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> > From: Daniel Jacobowitz <drow@false.org>
> > > 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.
>
> Garbage would be seen by caller of a `long long' returning callee where GDB
> would return something smaller (like `int'). As GDB writes (not "reads") the
> register it just will write zero to one excessive but unused register. This
> register must be callee-saved (not caller-saved) by the ABI supporting `long
> long' return type and GDB already asserts the return type is
> RETURN_VALUE_REGISTER_CONVENTION.

Thinking a bit more of this now, things all depend on the calling
convention. I'm not convinced casting to `long long' is safe in all
cases, especially on 32-bit big-endian machines. It really might do
the wrong thing there, exposing garbage or the wrong 32 bits of the
64-bit value.

The 'int' case is really special in a sense, very much because of the
K&R heritage. It has to work for all types that are sizeof(int) or
smaller.