This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__builtin_return_address()
- To: gcc at gcc dot gnu dot org
- Subject: __builtin_return_address()
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- Date: 22 Jul 2001 19:09:30 +0200
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.
Falk