my code breaks unique pointer rule?

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top