[Issue 21482] New: dynamic indexing into enum dynamic array at ctfe generates TypeInfo in betterC

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 15 01:15:23 UTC 2020


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

          Issue ID: 21482
           Summary: dynamic indexing into enum dynamic array at ctfe
                    generates TypeInfo in betterC
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dave287091 at gmail.com

Compiling with DMD, with -betterC

DMD64 D Compiler v2.094.2-336-g97aa2ae5e

// works
int f_1(int a){
    enum int[]foo = [1,2,3];
    if(__ctfe)
        return foo[1];
    return 1;
}

// works
int f_2(int a){
    static immutable int[] foo = [1,2,3];
    if(__ctfe)
        return foo[a];
    return 2;
}
// fails with TypeInfo cannot be used with -betterC
int f_3(int a){
    enum int[]foo = [1,2,3];
    if(__ctfe)
        return foo[a]; // Error is reported at this line.
    return 3;
}

All three work with ldc.

--


More information about the Digitalmars-d-bugs mailing list