Skip to main content
9 events
when toggle format what by license comment
Feb 23, 2018 at 4:35 comment added Dmytro in windows x86 cdecl this is stored in ecx register(this is faster, but since ecx is not accessible to C without assembly); with stdcall, it's stored on the stack as actual first(last to be pushed) argument. This allowed microsoft COM components to be usable from both C and c++ without having to use assembly to access this, or to pass this.
Aug 29, 2014 at 12:47 comment added Simon B Where "this" is stored is the sort of thing that the C++ standard deliberately avoids specifying. That way the compiler writer can determine the most efficient implementation for the particular processor and operating system. In practice, it is very likely to be either on the stack or in a register. It is an ephemeral thing - it only needs to exist while the function is executing, and can be deleted as soon as the function returns.
Aug 29, 2014 at 4:50 comment added Basile Starynkevitch No, this (or _this in the example) is a formal argument, it is not a local variable in main (or any other function)
Aug 29, 2014 at 4:02 comment added quant But you sort of answered that with the last line; I guess I was hoping the standard would have some definition for this, becuase it has important implications in cache management, particularly false sharing.
Aug 29, 2014 at 4:02 comment added quant In your example _this is stored in memory wherever it is declared, probably in main() somewhere when you declare your instance of A, or maybe it's a temporary. Supposing then that this is how the compiler "really does it", my question would be where does the compiler's "implicit" _this get instantiated?
Aug 29, 2014 at 0:34 history edited Rufflewind CC BY-SA 3.0
added 1 character in body
Aug 29, 2014 at 0:27 history edited Rufflewind CC BY-SA 3.0
added 59 characters in body
Aug 29, 2014 at 0:15 history edited Rufflewind CC BY-SA 3.0
added 59 characters in body
Aug 29, 2014 at 0:10 history answered Rufflewind CC BY-SA 3.0