I posted this question on a forum in MSDN [Prev question] (https://social.msdn.microsoft.com/Forums/vstudio/en-US/751fd20b-896e-494c-953e-a618b8cf5247/why-was-the-address-operator-overloaded-in-safeint-class?forum=vcgeneral#b28efc1c-8ce2-4ddf-b8cf-4a0773c064bb
It was wrongly worded and I didn't get a satisfactory response.
I am reporting this as a bug. Let me know if this isn't a bug.
I have a huge code base which I am migrating to use SafeInt<T,E>. The integer types in my code have been typedef'd to userdefined types for ease of modification of types.
For ex: situations like moving to SafeInt<T,E>. My issue pertains to the fact that &(address operator) has been overloaded to return T* instead of SafeInt<T, E> * .
Consider the following snippet.
void someFunction(MyInt* intPointerArgument); //Function signature I have.
MyInt anIntVar = 10;
//Contents of SomeHeaderWithTypedefs.h
typedef int MyInt;
typedef SafeInt<int> MyInt;
Changing the above typedef to point to SafeInt should not break my code where I send address of "MyInt" to the function.
It breaks because the &(address operator) has been overloaded to return T* for "ease of use". This breaks basic functionality and should not be so.
To fix the above code I have to change everyplace I try to use the address of MyInt to the following
I hope this is a convincing argument to categorize this functionality as a bug.