I am curious to know to behavior of register storage specifier in C/C++. Following program valid in C++, but in case of C it's not valid.
int main()
{
register int i;
int* b = &i; // Valid in C++ but not in C
}
So, My question I, Why C++ allowed address operator(&) to a register variable?
P.S : I know register storage specifier is deprecated in modern compiler.
Your answer can be found here:
http://en.cppreference.com/w/cpp/language/storage_duration
In C, the address of a register variable cannot be taken, but in C++, a variable declared register is semantically indistinguishable from a variable declared without any storage class specifiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With