Crash in struct opAssign

olivier h at h.invalid
Thu Dec 2 05:01:29 PST 2010


Hi,

This program, compiled with dmd 1.065 under Linux, crashes:

void main() {
	Num a = 1;
}

struct Num {
	int[] d;

	Num opAssign( int v ) {
		d.length = 1;
		d[0] = v;
		return *this;
	}
}

It looks like d is not initialized before opAssign() is called.
It doesn't crash if I replace "Num a = 1" with:
Num a;
a = 1;

Is this normal behaviour?


More information about the Digitalmars-d-learn mailing list