Is this documented behaviour?

John Colvin john.loughran.colvin at gmail.com
Tue Jul 23 09:34:51 PDT 2013


void foo(ref int a)
{
	a = 5;
}

void main()
{
	int a = 0;
	int* aptr = &a;
	
	foo(*aptr);
	assert(a == 5);
	
	a = 0;
	
	int b = *aptr;
	foo(b);
	assert(b == 5);
	assert(a == 0);
}

The fact that adding an explicit temporary changes the semantics 
seems weird to me.


More information about the Digitalmars-d-learn mailing list