Bug 16505 – Enable @nogc emplace

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-09-17T16:09:00Z
Last change time
2016-09-17T16:59:54Z
Keywords
CTFE
Assigned to
nobody
Creator
Marco.Leise

Comments

Comment #0 by Marco.Leise — 2016-09-17T16:09:09Z
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.