www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22050] New: -betterC silent crash when compiling map

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

          Issue ID: 22050
           Summary: -betterC silent crash when compiling map returning
                    string
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mipri minimaltype.com

This program fails to compile with no output from dmd:

```
import std.algorithm, std.range, std.conv;

void foo() {
    assert(2 == iota(2).map!(n => to!string(n)).length);
}
```

Shell session:

```
$ dmd -c bclife.d || echo failed
$ dmd -betterC -c bclife.d || echo failed
failed
$ dmd -betterC -c bclife.d -v |tail -1
import    core.internal.lifetime       
(/home/mipri/dmd2/linux/bin64/../../src/druntime/import/core/internal/lifetime.d)
```

This behavior is seen also with a just-compiled devel dmd.

s/string/float/ and it's fine.

it silently crashes elsewhere with "".dup instead of to!string(n):

```
semantic2 bclife3
semantic3 bclife3
import    core.stdc.string     
(/home/mipri/dmd2/linux/bin64/../../src/druntime/import/core/stdc/string.d
```

Most other variations that I've tried hit expected betterC errors.

--
Jun 20 2021