__builtin_return_address (0) and inlining

Eric Christopher echristo@redhat.com
Thu Jun 6 17:01:00 GMT 2002


>  >> > When converted, __builtin_return_address(0) will properly return
>  >> the > RA for the function it gets inlined into, rather than an
>  >> unpredictable > value.
>  >> 
>  >> That's still probably not what the person who wrote
>  >> __builtin_return_address(0) wanted.
>  >> 
> 
>  Eric> I'd agree with this. I think that this behavior would be
>  Eric> unexpected.
> 
> Perhaps, but it could be documented as such, and at least it's then a
> meaningful value.
> 
> One use for __builtin_return_address() is to print a stack trace for
> debugging.  A reasonable expectation is that printing
> __builtin_return_address(i) for i = 0..n will produce the same
> sequence of information as "bt" in gdb would show.  And I think that's
> what the proposal will do.  
> 

Right. That is what is happening currently on mips - at least for all of
the tests I can find. Cleaning up the argument passing,etc is on my
list. Of course, the list is huge. :)

If this is the way we want to go, I'll work up a doc patch explaining
it.

-eric

-- 
I will not carve gods



More information about the Gcc mailing list