Hello everyone,
Unique pointer should not allow aliasing. But my code which contains unique pointer aliasing and also compile/run ok. Anything wrong?
thanks in advance,
George
Unique pointer should not allow aliasing. But my code which contains unique pointer aliasing and also compile/run ok. Anything wrong?
Code:
__interface IFoo {
public:
virtual int foo ([unique] char *ptr1, [unique] char *ptr2) = 0;
};
class Foo : public IFoo {
public:
int foo (char *ptr1, char *ptr2)
{
char array1[] = "Hello";
ptr1 = array1;
ptr2 = array1; // should be wrong, no aliasing allowed, but compile and run ok
return 0;
}
};
int main()
{
char* ptr1 = 0;
char* ptr2 = 0;
Foo f;
f.foo(ptr1, ptr2);
return 0;
}
thanks in advance,
George