Daniel Jacobowitz <[EMAIL PROTECTED]> writes: > > The following program illustrates that __builtin_return_address seg faults > > when > > you reach the top of the stack rather than returning 0 as it is specified in > > the gcc manual. > > > > I see the same behaviour with both gcc 2.95 and gcc 3.0. > > GCC 3.2 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' or a random value. In addition, > `__builtin_frame_address' may be used to determine if the top of > the stack has been reached.
Well, that's not what my documentation from GCC 2.95 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'. I'm puzzled why I can use __builtin_frame_address to determine if the top of the stack has been reached but gcc's builtin can't do the same for me. I must be missing something, how do gdb and other tools happily decode stack traces all the time without crashing? -- greg