This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

__builtin_return_address()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]