[Issue 24440] [REG 2.107] multiple multidimensional array appends broke in 2.107

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 19 17:30:58 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24440

Yui Hosaka <hos at hos.ac> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hos at hos.ac

--- Comment #4 from Yui Hosaka <hos at hos.ac> ---
Sorry if this is unrelated, but I'm trying to add an example with similar
behavior. The following code, given `1000 1000` on the first line and 1000
tokens in each of the subsequence 1000 lines from standard input, fails to run
successfully and it is just "Segmentation fault" (DMD>=2.107.0, WSL2).


```
import std.conv, std.stdio, std.string;

void main() {
  string[] tokens = readln.chomp.split;
  const M = tokens[0].to!int;
  const N = tokens[1].to!int;
  auto A = new string[][](M, N);
  foreach (x; 0 .. M) {
    tokens = readln.chomp.split;
    foreach (y; 0 .. N) {
      A[x][y] = tokens[y];
    }
  }
}
```

For further info, I found this at when solving a problem at
https://yukicoder.me/ - my submission link:
https://yukicoder.me/submissions/974786 where I see that when the input is
smaller the segmentation fault does not happen (RE (Runtime Error) vs WA (Wrong
Answer)).

--


More information about the Digitalmars-d-bugs mailing list