www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24464] New: [REG 2.107.0] CTFE error when trying to allocate

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

          Issue ID: 24464
           Summary: [REG 2.107.0] CTFE error when trying to allocate an
                    array in betterC mode
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: betterC, CTFE
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: spoov0.707 gmail.com

```
int f()() => new int[](1)[0];
pragma(msg, f());
```
Compiling the code above with DMD 2.106.1 using the command
dmd -c -betterC test.d
produces the correct result
0

Since DMD 2.107.0 the following error gets generated:
test.d(1): Error: expression `new int[](1u)` allocates with the GC and cannot
be used with switch `-betterC`
test.d(2): Error: CTFE failed because of previous errors in `f`
test.d(2):        while evaluating `pragma(msg, f())`

--
Mar 28