Bug 5545 – [64-bit] DMD fails to postincrement ubytes.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2011-02-07T16:38:00Z
Last change time
2011-02-07T22:34:30Z
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2011-02-07T16:38:10Z
I apologize for the length of this test case, it was reduced from a ~1500 line file with a failing unittest. The following bug seems to be caused by DMD failing to increment i in the struct Perm. It only happens under -O -release -m64. Omitting any of these flags makes this program work. Also, the call to enforce() is necessary to reproduce the bug. import std.stdio; bool enforce(bool value, lazy const(char)[] msg = null) { if(!value) { return false; } return value; } struct Perm { byte[3] perm; ubyte i; this(byte[] input) { foreach(elem; input) { enforce(i < 3); perm[i++] = elem; stderr.writeln(i); // Never gets incremented. Stays at 0. } } } void main() { byte[] stuff = [0, 1, 2]; auto perm2 = Perm(stuff); writeln(perm2.perm); // Prints [2, 0, 0] assert(perm2.perm[] == [0, 1, 2]); }
Comment #1 by bugzilla — 2011-02-07T22:34:30Z