I know the concept of register variable and it\'s use cases but there are few questions in my mind based on what I have tried.
I cannot access the address
First, let's take a look at the relevant standards. It's always possible that C and C++ have different meanings for this keyword.
C++ 2011 Section 7.1.1 Paragraphs 2 and 3:
The register specifier shall be applied only to names of variables declared in a block (6.3) or to function parameters (8.4). It specifies that the named variable has automatic storage duration (3.7.3). A variable declared without a storage-class-specifier at block scope or declared as a function parameter has automatic storage duration by default.
A register specifier is a hint to the implementation that the variable so declared will be heavily used. [ Note: The hint can be ignored and in most implementations it will be ignored if the address of the variable is taken. This use is deprecated (see D.2). — end note ]
C 2011 Section 6.7.1 Paragraph 6 and Footnote 121:
A declaration of an identifier for an object with storage-class specifier register suggests that access to the object be as fast as possible. The extent to which such suggestions are effective is implementation-defined.)
The implementation may treat any register declaration simply as an auto declaration. However, whether or not addressable storage is actually used, the address of any part of an object declared with storage-class specifier register cannot be computed, either explicitly (by use of the unary & operator as discussed in 6.5.3.2) or implicitly (by converting an array name to a pointer as discussed in 6.3.2.1). Thus, the only operators that can be applied to an array declared with storage-class specifier register are sizeof and _Alignof.
So, let's take away what we've learned here.
As to what you're seeing in practice:
register int, so let's move past that.register. In this case, it would be good to show your test, because there may be problems in the test itself. If the full test is fine, then it certainly is possible that your compiler is using the hint to produce better code.for (int i=0; i<100; ++i){} and for (register int i=0; i<100; ++i) {}.