Extremely funny behavior .. could be a bug?
seany via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 12 12:16:56 PDT 2014
On Friday, 12 September 2014 at 15:26:34 UTC, Ali Çehreli wrote:
you are right, it was a reduced form, of a very complex software.
in file a.d
module a;
class class_a
{
struct RESULT{
string[] raw;
void* res;
}
RESULT * r;
void dothing()
{
r = new RESULT;
string aa = "string";
r.raw ~= aa;
r.res = cast(void*) aa;
}
}
in file b.d
import a; // import path is okey
class class_b
{
void doThings(class_a * ptr_a)
{
class_a A = *ptr_a;
writeln(A.r.raw[0]); // prints aa;
writeln(A.r.res); // fails :
core.exception.OutOfMemoryError@(0)
// but if i do comment the line :
// writeln(A.r.raw[0]); out, then
works
}
}
in file c.d
import a;
import b;
void main() {
clsa = new class_a;
clsb = new class_b;
clsa.dothing();
clsa.doThings( & clsa);
}
More information about the Digitalmars-d-learn
mailing list