www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15607] New: [ICE] CTFE internal error: bad compare on

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

          Issue ID: 15607
           Summary: [ICE] CTFE internal error: bad compare on accessing
                    default-initialized static immutable array of array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice, ice-on-valid-code
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com
                CC: public dicebot.lv

The following code:

```
private static immutable char[2][ubyte.max + 1] code_base = [ 0: "??" ];
static assert(code_base[0] == "??");
static assert(code_base[1] == typeof(code_base[1]).init);
```

results in:
crash.d(3): Error: CTFE internal error: bad compare
core.exception.AssertError ctfeexpr.d(1367): Assertion failure
----------------
??:? _d_assert [0x6cb907]
??:? void ddmd.ctfeexpr.__assert(int) [0x4f53b4]

This is just a manifestation of what I believe is a wider bug.
E.g. the following:

```
private static immutable char[2][ubyte.max + 1] code_base;
static assert(code_base[1] == typeof(code_base[1]).init);
```

Results in:
```
crash.d(3): Error: static variable code_base cannot be read at compile time
crash.d(3):        while evaluating: static assert(code_base[1] == ['\xff',
'\xff'])
```

Tested with 2.066, 2.069 and master (DMD64 D Compiler v2.069-devel-1adb2f0)
And it's a D1 regression ;)

--
Jan 25