Bug 21497 – "Error: unknown" for generating struct using CTFE

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-20T16:28:49Z
Last change time
2024-12-13T19:13:34Z
Keywords
CTFE, ice, rejects-valid
Assigned to
No Owner
Creator
Tim
Moved to GitHub: dmd#19843 →

Comments

Comment #0 by tim.dlang — 2020-12-20T16:28:49Z
//////////////// test.d //////////////// struct T { ubyte[16] data; } void assignZero(T)(ref T dst) { dst[] = 0; } static test = { T r; r.data.assignZero(); return r; }(); //////////////////////////////////////// dmd v2.094.2 gives the following error message when compiling: test.d(14): called from here: assignZero(r.data) test.d(16): called from here: (*function () pure nothrow @nogc @safe => r)() Error: unknown, please file report on issues.dlang.org
Comment #1 by tim.dlang — 2020-12-20T16:29:48Z
See also issues 20684 and 20753.
Comment #2 by b2.temp — 2023-01-08T19:47:17Z
reduced and rewritten to track the issue better: ``` struct T { ubyte[1] data; } void assignZero(ref ubyte[1] dst) { dst[] = 0; // dst[0 .. 1] = 0; eliminates the ICE } int getInit() { T r; assignZero(r.data); return 0; } enum int test = getInit(); ``` The problem seems to be related to CTFE + the slice assign lo and hi indexes + ref parameter.
Comment #3 by robert.schadek — 2024-12-13T19:13:34Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19843 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB