Creating a temporary object

Does anyone know if it is possible to enable any way of logging on any C ++ compatible compiler (Visual Studios, g ++, etc.) so that I can detect when temporary objects are created?

For instance:

Say I have a function f(char x) , but I call it with f(46)

I'll see in the magazines -

temporary char created promoting int @ function param f(46) (or something like this)

I read the VS compiler switch options, and it seems like this is not an option.

I understand that in the new standard there is the concept of rvalue reference (& &), which can be used to detect the majority of times for movement semantics, but this is due to the addition of a new compiler compatible with the / code. >

So can this be done? Or is it privileged compiler knowledge?

+4
source share
1 answer

What would be more useful are the built-in annotations in the IDE (since I assume you want to optimize while minimizing some of these paces?). In practice, the easiest way would be to modify GCC or g ++ and make them talk to the Visual Studio plugin or something like that. They could annotate the allocation of registers and all. Wow, that will really be helpful.

Prohibiting such an effort, and I don't know anything, the best way is to simply learn to read the assembly. In Visual Studio, you can assemble a compiled assembly in a row with a source, which is very useful.

0
source

Source: https://habr.com/ru/post/1441383/


All Articles