https://issues.dlang.org/show_bug.cgi?id=21424
Issue ID: 21424
Summary: Variable is incremented twice
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
The following code fails with dmd v2.094.1 under Linux x86_64:
int main()
{
ubyte[10] buf;
size_t pos = 0;
size_t num = 5;
buf[pos++] += num;
assert(pos == 1);
assert(buf[0] == 5);
assert(buf[1] == 0);
return 0;
}
Instead pos == 2, buf[0] == 0 and buf[1] == 5.
The same code works as expected with ldc and gdc.
--