Page MenuHomeFeedback Tracker

typename::Spawn constructor parameters are random memory
Closed, DuplicatePublic

Description

I am not 100% sure what the intended design for typename::Spawn is, if it should only work with the default constructor or not, but right now this code

class TestClass
{
    void TestClass(string param = "hello world")
    {
        PrintFormat(ToString() + "::ctor(%1)", param);
    }
}
...
Class test = String("TestClass").ToType().Spawn();
Print(test);

Results in this:

SCRIPT : TestClass<0x0000020514F1CD28>::ctor(ÈJü÷)
SCRIPT : Class test = TestClass<0x0000020514F1CD28>

I would have expected either "hello world" as the default value is known or an empty string or the constructor not being called at all in case the engine is hard wired to only call the parameterless constructor void TestClass(). Either way, I think one of these should be preferred over unassigned memory.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Aug 4 2022, 8:49 PM
Arkensor updated the task description. (Show Details)
Geez changed the task status from New to Assigned.Aug 8 2022, 11:03 PM