I tried the following with g++ 4.9.3:
int i = 0x1020;
char& ref1 = i; // Error. Makes sense to me
char const& ref2 = i; // No error. Does not make sense to me.
A problem I see:
char const* ptr1 = &i; // Error. Makes sense to me.
char const* ptr2 = &ref2; // No Error. Circumvents the error in the previous line
// without any ugly looking casts.
Is the code in the third line above legal by the C++ Standard? References to the supporting section(s) of the standard will be appreciated.