Passing an in parameter and aliasing

renoX renosky at free.fr
Sat May 26 10:11:53 PDT 2007


Thinking about it, you're right, but the hard thing is as always when 
you have func(in int[]array, int* p) that the programmer must not assume 
that array is unchanged because of the 'in' mode, it can be modified by 
the pointer reference (to prevent this the variable declaration must be 
change, the function parameter passing is not enough).

int f[1];
int* p=&f[0];
func(f,p)

func(in int[]array, int* p)
{
	*p = 1;
	/* here array[0] is 1 not 0 in this case */
}


renoX
PS: I couldn't read the thread linked by oskar linde as the web 
interface doesn't thread correctly the posts.



More information about the Digitalmars-d mailing list