[Issue 21424] New: Variable is incremented twice
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 24 22:34:01 UTC 2020
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: nobody at puremagic.com
Reporter: tim.dlang at t-online.de
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.
--
More information about the Digitalmars-d-bugs
mailing list