Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much bad can be done using register variables in C++

Tags:

People also ask

Can you have 100 register variables?

5) There is no limit on number of register variables in a C program, but the point is compiler may put some variables in register and some not.

What is the use of register variable in C?

Register variables tell the compiler to store the variable in CPU register instead of memory. Frequently used variables are kept in registers and they have faster accessibility. We can never get the addresses of these variables. “register” keyword is used to declare the register variables.

What is the lifetime of register variable?

Lifetime is till control remains within the block in which the register variable is defined. Example: register int x=5; Variables for loop counters can be declared as register. Note that register keyword may be ignored by some compilers.

Why register keyword is deprecated?

Introduction. The register keyword was deprecated in the 2011 C++ standard, as its effect was already implicit in the language. It remains reserved for future use by the standard, and is time to remove its vestigial specification.


I just came to know that we can use registers, explicitly in C++ programs. I wonder what if i declare and use all available registers in a single C++ program and run it for considerable amount of time. How badly will my system behave and what (if any) measures will be taken by the os to come out of the situation.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!