Bug 21009 – CTFE string concatenation with -betterC fails with: Error: TypeInfo cannot be used with -betterC
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2020-07-03T23:19:35Z
Last change time
2022-06-08T13:44:39Z
Keywords
betterC, CTFE
Assigned to
No Owner
Creator
Dentcho Bankov
Comments
Comment #0 by dbankov — 2020-07-03T23:19:35Z
There are a number of similar issues filed already (PR 18472 is probably the closest one) but think the string concatenation is quite important for CTFE (even with -betterC) so decided to file this PR as well.
The failing code is:
import core.stdc.stdio;
string genSubTypeDefinition()
{
string result = "enum SubType ";
result ~= "{ a = 0 }";
return result;
}
enum subTypeDefinition = genSubTypeDefinition();
mixin(subTypeDefinition);
extern(C) int main()
{
printf("SubType.a = %d", SubType.a);
return 0;
}
This code compiles with DMD 2.078.3.
Comment #1 by razvan.nitu1305 — 2022-06-08T13:44:39Z