[Issue 16505] New: Enable @nogc emplace

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Sep 17 09:09:09 PDT 2016


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

          Issue ID: 16505
           Summary: Enable @nogc emplace
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: CTFE
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: Marco.Leise at gmx.de

Phobos' emplace() cannot infer its attributes to include @nogc, if the type's
constructor cannot be run at compile-time. These two things are seemingly
unrelated, but it boils down to how supporting emplace() at compile time makes
use of language features that would be GC allocations at runtime:

        if (__ctfe)
        {
            […]
            // GC allocation at runtime:
            assert(0, "CTFE emplace doesn't support "
                ~ T.stringof ~ " from " ~ Args.stringof);
        }
        else
        {
            […]
        }

If "if (__ctfe)" blocks were exempted from (runtime) attribute inference, it
would work. A stop-gap-solution is to store the concatenation result in an
enum.

--


More information about the Digitalmars-d-bugs mailing list