Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22162

What happens with address of operator for variables that the compiler decides to put in registers?

$
0
0

I understand that in C, if a variable is explicitly specified with the register keyword, then one cannot use the & operator on it, and that makes sense to me that there's no such thing as "address" of a variable that's always kept in a register.

My question is, if the compiler decides on its own to store a variable in register rather than spilling it, then what happens with the & operator during code execution?

I can think of two ways that the compiler might try to handle this:

  1. Try to emulate the & behavior, but this seems hairy and I have no idea how one would do this rigorously and efficiently.
  2. Always spill a variable if the & operator is used with this variable.

Does C take one of these approaches or does it do something else in this case?


Viewing all articles
Browse latest Browse all 22162

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>