[Issue 24354] New: Static arrays are by-reference during CTFE
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 23 23:07:46 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24354
Issue ID: 24354
Summary: Static arrays are by-reference during CTFE
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE, wrong-code
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
The following function returns a different result at compile-time vs. runtime:
auto fun()
{
ubyte[1] arr = [0];
auto copy = arr;
copy[0] = 42;
return arr;
}
// E.g.
void main()
{
static ct = fun();
assert(ct == fun());
}
I think this a regression introduced in https://github.com/dlang/dmd/pull/3467.
--
More information about the Digitalmars-d-bugs
mailing list