Temporary static arrays on stack get corrupted with dmd -m64
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu May 10 12:06:12 PDT 2012
On Wed, May 09, 2012 at 11:06:09PM -0700, H. S. Teoh wrote:
> 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?
[...]
Since nobody replied, I opened a new bug:
http://d.puremagic.com/issues/show_bug.cgi?id=8079
It may be related to bug 5570 perhaps? In any case, this is a
deal-breaker for me, as it makes 64-bit unusable with dmd. I have no
choice but to go back to gdc, but my distro's gdc doesn't work with
2.059 phobos yet, and I need the new regex support. :-(
T
--
Tech-savvy: euphemism for nerdy.
More information about the Digitalmars-d
mailing list