Hello JPF,
Hi,
I've come across some strange behavior using delegating constructors
and
assignment to this. Please have a look a this testcase:
--------------------------------------
class Test
{
static Test[void*] lookupTable;
public int i = 0;
public this (void* ptr)
{
//Check if there already is a D object for this ptr
if(ptr in lookupTable)
{
this = lookupTable[ptr];
assert(this.i == 15); /* ok */
return;
}
'this' is a mutable *local* reference (IIRC it is in fact a hidden 1st argument
to the function). All the 'this =' lines does is assign to a local value
that is discarded immediately. If asserts are turned off, the optimizer would
even be free to just dump the then clause from that code as a dead assignment.
('this' being mutable might be considered a bug in the spec)
--
<IXOYE><