Came across this one while browsing the response to another question on SO (References Vs Variable Gets). My question is that for all 64bit environments is it guaranteed that a reference to a variable will be of 64 bits even if the original had a lesser size? As in char references in 64bit environment would be >sizeof(char)? Is there any section in the standard which specifies this explicitly?
EDIT: For more clarity -- char c1 = 'a'; char& c2 = c1; My question is sizeof(c2) > sizeof(c1) in 64bit machines?
The Standard (ISO C++-03) says the following thing about references
It is unspecified whether or not a reference requires storage (3.7).
Please someone correct me if I am wrong or if I have not understood his question correctly.
EDIT:
My question is sizeof(c2) > sizeof(c1) in 64bit machines?
No, as @Chubsdad noticed sizeof(c2) = sizeof (c1)
, the relevant quote from the Standard is
When applied to a reference or a reference type, the result is the size of the referenced type
. (ISO C++ $5.3.3/2)
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