Bug 24078 – [REG] crash related to concatenation

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-08-08T13:33:44Z
Last change time
2023-09-16T07:31:12Z
Keywords
pull
Assigned to
No Owner
Creator
Basile-z

Comments

Comment #0 by b2.temp — 2023-08-08T13:33:44Z
The following code ``` void main() { import std.stdio; auto a = ["c"]; writeln( a ~ "a"); // OK writeln( a ~ "a" ~ "b"); // CRASH } ``` used to work and output the right result but it crashes at runtime since recently. Same problem verified with latest LDC (DMD 2.104.+), showing that the problem might be a caused by a buggy lowering.
Comment #1 by naydef — 2023-08-09T12:06:38Z
Comment #2 by b2.temp — 2023-08-10T14:53:39Z
reduced w/o phobos ``` extern(C) int puts(const char*); void main() { auto a = ["c\0"]; foreach (v; a ~ "a\0" ~ "b\0") puts(v.ptr); } ```
Comment #3 by dlang-bot — 2023-08-19T01:16:58Z
@teodutu created dlang/dmd pull request #15543 "Fix Issue 24078 - Fold constants on array concatenation only for strings" fixing this issue: - Fix Issue 24078 - Fold constants on array concatenation only for strings Without this limitation, the code could incorrectly concatenate `["c"] ~ "a" ~ "b"` as `["c"] ~ "ab"`, which was incorrect. Signed-off-by: Teodor Dutu <[email protected]> https://github.com/dlang/dmd/pull/15543
Comment #4 by dlang-bot — 2023-08-19T08:22:03Z
dlang/dmd pull request #15543 "Fix Issue 24078 - Fold constants on array concatenation only for strings" was merged into stable: - c0de9a32d21bd15ca3ca4c0baaea3a6844122e2d by Teodor Dutu: Fix Issue 24078 - Fold constants on array concatenation only for strings Without this limitation, the code could incorrectly concatenate `["c"] ~ "a" ~ "b"` as `["c"] ~ "ab"`, which was incorrect. Signed-off-by: Teodor Dutu <[email protected]> https://github.com/dlang/dmd/pull/15543
Comment #5 by dlang-bot — 2023-09-16T07:31:12Z
dlang/dmd pull request #15609 "merge stable" was merged into master: - b349b6d0de9d375bda2db418fb16fabe7fc2f031 by Teodor Dutu: Fix Issue 24078 - Fold constants on array concatenation only for strings Without this limitation, the code could incorrectly concatenate `["c"] ~ "a" ~ "b"` as `["c"] ~ "ab"`, which was incorrect. Signed-off-by: Teodor Dutu <[email protected]> https://github.com/dlang/dmd/pull/15609