MSVC equivalent to '__builtin_return_address'

With msvc, is there a gcc equivalent of "__builtin_return_address"?

I am looking to find the address of the calling function, 1 level deep.

+4
source share
1 answer

__ ReturnAddress

From MSDN:

The built-in _ReturnAddress instruction address in the calling function, which will be executed after control returns to the caller

Note that on some platforms, the result may be misleading due to tail bending - the compiler may have an internal function returning 2 levels. This can usually happen for the code:

int DoSomething() { return DoSomethingSpecial(); } 

The compiler can generate code, so DoSomethingSpecial returns DoSomething directly to the caller.

In addition, the return address is not trustworthy - enough to make security decisions, see here .

+9
source

All Articles