www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21009] New: CTFE string concatenation with -betterC fails

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 puremagic.com
          Reporter: dbankov 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.

--
Jul 03