76

Re: Constant copy of a class. Who as does?

MasterZiv wrote:

Well and?
Topic I close?

to solve

77

Re: Constant copy of a class. Who as does?

NekZ wrote:

it is passed...
I about it wrote more low, passing from the bare theory to a reality.

If to pass to a reality in your example no copy of a class at all forms - anywhere, and the compiler on-O3 replaces a method of object and its member-variable with a functional equivalent, i.e., it is simple  jmp on rand () from main.

78

Re: Constant copy of a class. Who as does?

MasterZiv wrote:

Well and?
Topic I close?

In general, ground already everything that only it was possible to grind and "in" and "nearby". Close, if this canoe bothered.

79

Re: Constant copy of a class. Who as does?

rdb_dev wrote:

If to pass to a reality in your example no copy of a class at all forms - anywhere, and the compiler on-O3 replaces a method of object and its member-variable with a functional equivalent, i.e., it is simple  jmp on rand () from main.

He-he so in that also there was an essence of everything that I to you repeat already the third page of a topic.
Yes even on-O1 remains only jmp.

80

Re: Constant copy of a class. Who as does?

NekZ wrote:

He-he so in that also there was an essence of everything that I to you repeat already the third page of a topic.
Yes even on-O1 remains only jmp.

Told' you, of course, told', but the object both was not, and is not present, and we speak about objects.

81

Re: Constant copy of a class. Who as does?

MasterZiv wrote:

0) placement new it is not redefined.
1) the code placement new is a call  with specified by placement pointer on storage in a type this.
2) accordingly, the code placement new always . It actually one function invocation.

Yes throw! All is perfectly redefined:

void* operator new (size_t size, void *p)
{
return p;
}

82

Re: Constant copy of a class. Who as does?

rdb_dev wrote:

Told' you, of course, told', but the object both was not, and is not present, and we speak about objects.

In the terminal of language of the assembler generally objects are not present, it is pure that convenient facade for programmers that they did not see all . And such here the optimization, any mentions throwing out generally there of your class and it  from the total assembler, show to you that are not present any phases of selection of storage on a stack and a call placement new , they exist only in your consciousness.

83

Re: Constant copy of a class. Who as does?

NekZ;
In *

84

Re: Constant copy of a class. Who as does?

NekZ wrote:

In the terminal of language of the assembler generally objects are not present, it is pure that convenient facade for programmers that they did not see all .

Objects are not present not in assembler terms, and in terms of the machine codes, and in terms of the assembler it quite to itself(himself) exists and, and, with the virtual methods. For example, in TASM.

NekZ wrote:

And such here the optimization, any mentions throwing out generally there of your class and it  from the total assembler, show to you that are not present any phases of selection of storage on a stack and a call placement new , they exist only in your consciousness.

Yes that you speak? Try at to add by the maximum optimization the qualifier volatile to method declaration MyClass:: f * (), to the declaration of a copy of a class collect and be surprised to "force of my consciousness". smile))

85

Re: Constant copy of a class. Who as does?

rdb_dev wrote:

Yes that you speak? Try at to add by the maximum optimization the qualifier volatile to method declaration MyClass:: f * (), to the declaration of a copy of a class collect and be surprised to "force of my consciousness". smile))

Give.

#include <cstdlib>
#include <new>
#include <malloc.h>
struct MyClass {int x; MyClass () {x = rand ();} int f () volatile {return x;}};
int main ()
{
volatile MyClass foo;
return foo.f ();
}

clang-O3

main: # @main
push rax
call rand
mov dword ptr [rsp + 4], eax
mov eax, dword ptr [rsp + 4]
pop rcx
ret

Where storage selection under object?

86

Re: Constant copy of a class. Who as does?

NekZ wrote:

Where storage selection under object?

[quote =] push rax

?