Search code examples
c++temporary

How's a temporary implemented in C++?


In the following 'a' is a temporary.

cout << 'a';

It isn't restored in the data section (const/static does) and shouldn't be in the stack (local variable does). Where is it?

UPDATE

Are non-lvalue and rvalue the same thing?


Solution

  • Unless you have a really horrible compiler or machine architecture, 'a' is not stored as data anywhere. It's an immediate operand in the asm, e.g.

    mov $0x97, %eax