www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23460] New: ICE in some cases when trying to infer an

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

          Issue ID: 23460
           Summary: ICE in some cases when trying to infer an exception
                    throwing function
           Product: D
           Version: D2
          Hardware: Other
                OS: Mac OS X
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy gmail.com

This file causes dmd to core dump (and ldc2 as well).

```d
import std.algorithm;
import std.array;
void main()
{
    auto r = "".map!(d => throw new Exception("blah")).array;
}
```

The stack trace in ldc2 is:

```
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  ldc2                     0x0000000107142758
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  ldc2                     0x0000000107141700 llvm::sys::RunSignalHandlers() +
72
2  ldc2                     0x0000000107142dac SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000019ec4f4a4 _sigtramp + 56
4  ldc2                     0x00000001074bf1d8 DtoStructEquals(EXP, DValue*,
DValue*) + 64
5  ldc2                     0x00000001074d2128 ToElemVisitor::visit(EqualExp*)
+ 1764
6  ldc2                     0x00000001074b6aec ToIRVisitor::visit(IfStatement*)
+ 744
7  ldc2                     0x00000001074bc638
ToIRVisitor::visit(CompoundStatement*) + 304
8  ldc2                     0x00000001074b4b90
ToIRVisitor::visit(ForStatement*) + 1568
9  ldc2                     0x00000001074bc638
ToIRVisitor::visit(CompoundStatement*) + 304
10 ldc2                     0x00000001074b2c00
ToIRVisitor::visit(ScopeStatement*) + 284
11 ldc2                     0x00000001074bc638
ToIRVisitor::visit(CompoundStatement*) + 304
12 ldc2                     0x00000001074bc638
ToIRVisitor::visit(CompoundStatement*) + 304
13 ldc2                     0x0000000107489050
DtoDefineFunction(FuncDeclaration*, bool) + 14852
14 ldc2                     0x0000000107477b64
CodegenVisitor::visit(TemplateInstance*) + 320
15 ldc2                     0x0000000107497cc0 codegenModule(IRState*, Module*)
+ 3140
16 ldc2                     0x0000000107513fe8 codegenModules(Array<Module*>&)
+ 3392
17 ldc2                     0x0000000107448a34 mars_mainBody(Param&, Array<char
const*>&, Array<char const*>&) + 4088
18 ldc2                     0x00000001075f9090
_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 116
19 ldc2                     0x00000001075f8d28 _d_run_main + 148
20 ldc2                     0x000000010750e5b0 main + 768
21 dyld                     0x000000010aca508c start + 520
zsh: segmentation fault  ldc2 badcode.d
```

If that helps at all. 

If I change the array type to an int array, it compiles successfully on ldc,
but still crashes with dmd.

This should work and typeof(r) should be `noreturn[]` (verified with the
working integer version on ldc2)

--
Nov 04 2022