12.6.7.13 CPP0012 - Heap Allocation of Value Type

Description

Extern classes or enums annotated with cpp.ValueType cannot be directly allocated to the heap. Some Haxe code can be ambiguous about this, to avoid any confusion the ambiguous code is forbidden.

Examples

The following examples generate CPP0012.

@:semantics(value)
@:cpp.ValueType
extern class Foo {
    function new():Void;
}

function main() {
    final f : cpp.Star<Foo> = cast new Foo(); // CPP0012
    final f : cpp.Pointer<Foo> = cast new Foo(); // CPP0012
    final f : cpp.RawPointer<Foo> = cast new Foo(); // CPP0012
}