[Issue 22334] New: TypeInfo is used in inexplicable places
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 24 09:10:48 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22334
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 at puremagic.com
Reporter: zan77137 at 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;
tmp.text._ctfeAppend(str[0]);
ret._ctfeAppend(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;
foo!dat(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:
https://issues.dlang.org/show_bug.cgi?id=18472
--
More information about the Digitalmars-d-bugs
mailing list