Temporary static arrays on stack get corrupted with dmd -m64
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed May 9 23:06:09 PDT 2012
Code (compile with dmd -m64):
import std.stdio;
struct S {
short[4] x;
this(short[4] args...) {
x[] = args[];
}
bool opEquals(in S s) const {
for (auto i=0; i < 4; i++) {
if (this.x[i] != s.x[i])
return false;
}
return true;
}
}
void main() {
assert(S(1,2,3,4) == S(1,2,3,4));
}
Output: the assertion in main fails. Inserting writeln's indicate that
the parameter s to opEquals is corrupted (has garbage values). Trying to
writeln either argument causes a segfault.
Compiling with -m32 works no problem.
Is this a known issue?
T
--
This is a tpyo.
More information about the Digitalmars-d
mailing list