[Issue 21009] New: CTFE string concatenation with -betterC fails with: Error: TypeInfo cannot be used with -betterC
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 3 23:19:35 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21009
Issue ID: 21009
Summary: CTFE string concatenation with -betterC fails with:
Error: TypeInfo cannot be used with -betterC
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dbankov at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list