← Back to index
|
Original Bugzilla link
Bug 19938 – CTFE duplicates calls to function when it is used as LHS of slice assignment
Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-06-04T15:12:57Z
Last change time
2024-12-13T19:03:46Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Eyal
Moved to GitHub: dmd#19577 →
Comments
Comment #0
by eyal — 2019-06-04T15:12:57Z
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()); }
Comment #1
by eyal — 2019-06-05T07:45:13Z
Slightly simplified: auto check() { int count; int[] x() { count++; return []; } x()[] = 1; assert(count == 1); // fails in CTFE only, where count == 2, LHS calls are duplicated in CTFE return true; } unittest { cast(void)check(); // works static assert(check()); }
Comment #2
by robert.schadek — 2024-12-13T19:03:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/19577
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB