Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6625289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:45:22+00:00 2026-05-25T21:45:22+00:00

Possible Duplicate: What is the difference between r-value references and l-value references? (CodeGen) I

  • 0

Possible Duplicate:
What is the difference between r-value references and l-value references? (CodeGen)

I was wondering, can anyone explain what R-Value references are on a technical level? By that I mean: What happens on assembler level when R-Value references are created.

For a small test to see what happens inside I wrote the following code:

char c = 255;
char &c2 = c;
char &c3 = std::move(c);

I know it makes no sense to create a R-Value reference to ‘c’, but just for the sake of testing I did it anyway, to see what it does. And here’s the result:

unsigned char c = 255;
    mov         byte ptr [c],0FFh
unsigned char &c2 = c;
    lea         eax,[c]  
    mov         dword ptr [c2],eax 
unsigned char &&c3 = std::move(c);
    lea         eax,[c]  
    push        eax  
    call        std::move<unsigned char &> (0ED1235h)  
    add         esp,4  
    mov         dword ptr [c3],eax

I am by far no asm expert but it looks to me that, in this case, ‘c3’ is a regular reference to ‘c’ in the end.

If I bind the R-Value reference directly to a temporary (char &&c3 = 255), the last bit of assembler changes as such:

unsigned char &&c3 = 255;
    mov         byte ptr [ebp-29h],0FFh  
    lea         eax,[ebp-29h]  
    mov         dword ptr [c3],eax

From the looks of this change, I assume that c3 still actually is a reference to some memory location which holds the value 255. So it’s a regular reference – the value is not copied/assigned to c3. Is this true?

Can anyone say if my assumptions are correct or if I am totally off the track? Until now I always thought of R-Value references to match a functions/methods signature (possibly a move-ctor) when it comes to calling resolution, so that the coder knows how to treat the data that is provided (for a move-ctor that would be moving the data instead of copying it).

To defend this rather stupid attempt I just presented: I don’t intend to screw around with my code on asm level, I just want to unterstand what technical differences R-Value references introduced compared to the rest that has been around all these years.

Any insights and explanations are more than welcome!

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:45:22+00:00Added an answer on May 25, 2026 at 9:45 pm

    What happens on assembler level when R-Value references are created.

    Whatever is needed to preserve high-level semantics. What compiler does exactly depends on what compiler vendor thought would be a good idea. Assembly has no concept of lvalues, rvalues, or references, so stop looking for them. Turn on the optimisations, and the code you’re looking at will probably change (or might stop existing at all, if the variables are not used).

    I just want to unterstand what technical differences R-Value references introduced compared to the rest that has been around all these years.

    Rvalue references enable move semantics, and those in turn enables important optimisation opportunities. The standard doesn’t say “oh, these are rvalue refs, and that’s how you should implement them in assembly”. Implementation might not even produce assembly, at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Difference between i++ and ++i in a loop? Can anyone explain what's
Possible Duplicate: c difference between malloc and calloc Please explain the significance of this
Possible Duplicate: Difference between ref and out parameters in .NET I know that ref
Possible Duplicate: Difference among Double.MIN_NORMAL and Double.MIN_VALUE 1) Can some one pls explain to
Possible Duplicate: What's the difference between passing by reference vs. passing by value? If
Possible Duplicate: What is the difference between (type)value and type(value)? If you have a
Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I
Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading
Possible Duplicate: What is the difference between a delegate and events? Possible Duplicate: Difference
Possible Duplicate: Ruby: difference between || and ‘or’ Using Ruby || and or are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.