[Issue 23729] ignore custom object.d for CTFE needs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 23 14:33:55 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23729

--- Comment #9 from ryuukk_ <ryuukk.dev at gmail.com> ---
Here a minimal reduced reproducer:


```
--- main.d
extern(C) void main()
{
    mixin (simpleFormat(q{
                        asm pure nothrow @nogc @trusted
                        {
                            naked;
                            ret;
                        }
                    }, []));
}


string simpleFormat(string format, scope string[] args)
{
    string result;
    outer: while (format.length)
    {
        foreach (i; 0 .. format.length)
        {
            if (format[i] == '%' || format[i] == '?')
            {
                bool isQ = format[i] == '?';
                result ~= format[0 .. i++];
                assert (i < format.length, "Invalid format string");
                if (format[i] == '%' || format[i] == '?')
                {
                    assert(!isQ, "Invalid format string");
                    result ~= format[i++];
                }
                else
                {
                    int index = 0;
                    assert (format[i] >= '0' && format[i] <= '9', "Invalid
format string");
                    while (i < format.length && format[i] >= '0' && format[i]
<= '9')
                        index = index * 10 + (ubyte(format[i++]) - ubyte('0'));
                    if (!isQ)
                        result ~= args[index];
                    else if (!args[index])
                    {
                        size_t j = i;
                        for (; j < format.length;)
                        {
                            if (format[j++] == '\n')
                                break;
                        }
                        i = j;
                    }
                }
                format = format[i .. $];
                continue outer;
            }
        }
        result ~= format;
        break;
    }
    return result;
}


--- object.d
module object;
pragma(msg, "-- using custom runtime --");

alias size_t = typeof(int.sizeof);
alias ptrdiff_t = typeof(cast(void*)0 - cast(void*)0);
alias noreturn = typeof(*null);

alias string  = immutable(char)[];
alias wstring = immutable(wchar)[];
alias dstring = immutable(dchar)[];

--


More information about the Digitalmars-d-bugs mailing list