www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22334] New: TypeInfo is used in inexplicable places


          Issue ID: 22334
           Summary: TypeInfo is used in inexplicable places
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: zan77137 nifty.com

This code doesn't work with `-betterC`:
void _ctfeAppend(T)(ref T[] store, T dat)
        static if (is(T U: const(U)))
                U[] buf;
                buf.length = 1;
                buf[0] = dat;
                store = cast(T[])buf;

void put(R, E)(R, E){}

struct Data{ string text;}

Data[] getData(string str)
        if (__ctfe)
                Data[] ret;
                Data tmp;
                return ret;
        return null;

void foo(Data dat, DstRange)(DstRange dst)
        put(dst, dat);

extern(C) void main()
        static immutable dat = getData("a")[0];
        char[] buf;

Even though the above code does not use TypeInfo at first glance, the compiler
says "Error: `TypeInfo` cannot be used with -betterC".

By the way, in CTFE, there should be no restriction on using TypeInfo, even if
it is betterC.
The issue related to the relaxation of the CTFE+BetterC restrictions relates to
the following:

Sep 24 2021