Bug 20400 – CTFE increasing length of array of characters changes its value

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-11-16T23:47:53Z
Last change time
2019-11-17T09:06:06Z
Assigned to
No Owner
Creator
Suleyman Sahmi (سليمان السهمي)

Comments

Comment #0 by sahmi.soulaimane — 2019-11-16T23:47:53Z
Test case: ``` auto test() { char[] s = cast(char[])"1234"; char[] ret = s[2 .. $]; ret.length += 1; ret[$-1] = '5'; return ret; } pragma(msg, test()); ``` output: 125 expected: 345
Comment #1 by dlang-bot — 2019-11-17T09:06:06Z
dlang/dmd pull request #10576 "Fix issue 20400 - increasing array length in CTFE corrupts its value" was merged into master: - 85fbe51c75e83c5327211fc409e445a6a4414ad3 by سليمان السهمي (Suleyman Sahmi): Fix issue 20400 - increasing array length in CTFE corrupts its value https://github.com/dlang/dmd/pull/10576