Here's some code:
-------------------------------------
class MyThing {
int x;
}
// Two identical arrays, typewise
MyThing arga[0];
MyThing argb[0];
// Create an instance
MyThing thing;
5 => thing.x;
// Push it into arga
arga << thing;
// Push it into argb
argb << thing;
<<< "n=", arga[0].x >>>;
<<< "n=", argb[0].x >>>;
// clear arga
0 => arga.size;
// clear argb - crash!
0 => argb.size;
-------------------------------------
when I run it I get:
-------------------------------------
$ chuck test.
ck
n= 5
n= 5
chuck_oo.cpp:120: failed assertion `m_ref_count > 0'
Abort trap
-------------------------------------
It seems that that 0 => arga.size decrements a reference count for thing, causing it to be freed, and then when the same thing is attempted for argb, it crashes. Possibly some reference increment missing when doing argb << thing ?
/Stefan
--
Release me, insect, or I will destroy the Cosmos!