Why register variable's address is allowed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why register variable's address is allowed

https://www.sololearn.com/compiler-playground/cAqtscflsNXj Refer code above. Why Solo learn allows address of register variable?

28th Feb 2023, 7:12 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Answers
+ 7
From what I understand, a register declaration is only a hint to the compiler to bias the optimization. It is not a guarantee that it will be exclusively register. If the compiler determines that it needs to use the stack, then it will. So I would guess that if the code refers to the variable's address, then the compiler will have to ignore the request to make it register-only.
28th Feb 2023, 9:07 AM
Brian
Brian - avatar
+ 4
28th Feb 2023, 9:31 AM
Ipang
+ 2
Thanks
28th Feb 2023, 11:45 AM
Ketan Lalcheta
Ketan Lalcheta - avatar