This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: __builtin_return_address()
On Sun, Jul 22, 2001 at 07:09:30PM +0200, Falk Hueffner wrote:
> Hi,
>
> I have a problem with __builtin_return_address(). This program:
>
> int main() {
> printf("%p\n", __builtin_return_address(0));
> printf("%p\n", __builtin_return_address(1));
> printf("%p\n", __builtin_return_address(2));
> }
>
> yields on alpha:
>
> 0x2000006a5ec
> (nil)
> (nil)
>
> which is consistent with the info page which says
>
> On some machines it may be impossible to determine the return
> address of any function other than the current one; in such cases,
> or when the top of the stack has been reached, this function will
> return `0'.
>
> On a i386, though, I get:
>
> 0x4003638b
> 0x804838d
> zsh: segmentation fault (core dumped) ./a.out
>
> Is this a bug in gcc, or is this simply unavoidable on i386? If so,
> the info page should mention it.
>
See
http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg00099.html
H.J.