[BUG] UObject Constructors cause Crashing that was not present before

I have this class called UMyObject:

in .h

#include "Object.h"
#include "MyObject.generated.h"

/**
 * 
 */
UCLASS()
class MONOCHROME_API UMyObject : public UObject
{
	GENERATED_BODY()
public:
		UMyObject();
	
	
};

In .cpp

#include "ProjectName.h"
#include "MyObject.h"


UMyObject::UMyObject(){}

In 4.6 I could easily instantiate this class by calling in another part of the code:

UMyObject* TestObject = new UMyObject();

But now in 4.7.1 it seems I can no longer.

I get an exception error, breaking takes me here:

UObject::UObject()
{
	FObjectInitializer* ObjectInitializerPtr = FTlsObjectInitializers::Top();
	UE_CLOG(!ObjectInitializerPtr, LogUObjectGlobals, Fatal, TEXT("%s is not being constructed with either NewObject, NewNamedObject or ConstructObject."), *GetName());
	FObjectInitializer& ObjectInitializer = *ObjectInitializerPtr;
	check(!ObjectInitializer.Obj || ObjectInitializer.Obj == this);
	const_cast<FObjectInitializer&>(ObjectInitializer).Obj = this;
	const_cast<FObjectInitializer&>(ObjectInitializer).FinalizeSubobjectClassInitialization();
}

with this line highlighted:

check(!ObjectInitializer.Obj || ObjectInitializer.Obj == this);

Is this as intended? Because judging by 4.7’s notes, and 4.6’s notes, I’m understanding that parameter-less constructors anywhere was an intended feature, and I was able to construct UObjects this manner in 4.6.

Any help would be greatly appreciated.

Yes, this is intended. Right now you can’t use “new” to create a UObject. You need to use one of mentioned functions to do this.

Because judging by 4.7’s notes, and 4.6’s notes, I’m understanding that parameter-less constructors anywhere was an intended feature, and I was able to construct UObjects this manner in 4.6.

You still can do it using NewObject, as it have all optional parameters. You only need to provide a UObject’s class as template parameter.

Thanks,
Jarek

Wow! Thanks for the quick response (really was not expecting it that soon)

Now I understand completely what the error message meant.

UMyObject* TestObject = NewObject<UMyObject>();