[Issue 19938] New: CTFE duplicates calls to function when it is used as LHS of slice assignment
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 4 15:12:57 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19938
Issue ID: 19938
Summary: CTFE duplicates calls to function when it is used as
LHS of slice assignment
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
struct foo {
int count;
int[] x() { count++; return []; }
}
auto check() {
foo f;
f.x[] = 1;
f.x[] = 2;
assert(f.count == 2); // fails in CTFE only, where f.count == 4, x() calls
are duplicated only in CTFE
return true;
}
unittest {
check(); // works
static assert(check());
}
--
More information about the Digitalmars-d-bugs
mailing list