Help with C1001

Hey there,

I’ve been somewhat boggled by this C1001 compile error I’ve been running into. It only happens when building for development editor builds in VC and hot reload in editor. It is not present in Debug editor builds at all.



c:\**\source\bblpnyutil\private\animationbatchmeta.cpp(104): fatal error C1001: An internal error has occurred in the compiler.
2>         (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 255)
2>          To work around this problem, try simplifying or changing the program near the locations listed above.
2>         Please choose the Technical Support command on the Visual C++
2>          Help menu, or open the Technical Support help file for more information
2>


Where line 104 of that file has the following function


bool UAnimationBatchMeta::GatherConfiguration(FAnimationBatchConfiguration & o) const { // <-- C1001

	bool any = false;

	o = FAnimationBatchConfiguration();

	for (TSubclassOf<UAnimationBatch> klass : Inherit) {
		any |= (*klass != nullptr) && klass.GetDefaultObject()->GetConfiguration(o);
	}

	any |= UAnimationBatch::Solidify(Overrides, o);
	return any;
}

if i replace the code found there with the following below it compiles…


bool UAnimationBatchMeta::GatherConfiguration(FAnimationBatchConfiguration & o) const {

	bool any = false;

	//o = FAnimationBatchConfiguration();

	//for (TSubclassOf<UAnimationBatch> klass : Inherit) {
	//	any |= (*klass != nullptr) && klass.GetDefaultObject()->GetConfiguration(o);
	//}

	//any |= UAnimationBatch::Solidify(Overrides, o);
	return any;
}

As long as I do not iterate the klasses it seems to compile…


bool UAnimationBatchMeta::GatherConfiguration(FAnimationBatchConfiguration & o) const {

	bool any = false;

	o = FAnimationBatchConfiguration();

	//for (TSubclassOf<UAnimationBatch> klass : Inherit) {
	//	any |= (*klass != nullptr) && klass.GetDefaultObject()->GetConfiguration(o);
	//}

	any |= UAnimationBatch::Solidify(Overrides, o);
	return any;
}

So i got to thinking it could be GetConfiguration which is a virtual function, so i replaced it as below and the C1001 returned again ( the error comes up fairly quick in both C1001 versions )


bool UAnimationBatchMeta::GatherConfiguration(FAnimationBatchConfiguration & o) const {// <-- C1001

	bool any = false;

	o = FAnimationBatchConfiguration();

	for (TSubclassOf<UAnimationBatch> klass : Inherit) {
		any |= (*klass != nullptr) && UAnimationBatch::Solidify( klass.GetDefaultObject()->Configuration, o);//<-- uses the same fuction that compiles after this loop.
	}

	any |= UAnimationBatch::Solidify(Overrides, o);
	return any;
}

So at this point I’m wondering if perhaps I’m using the “Inherit” member incorrectly or if there is some bug?
The “Inherit” member is declared as below for reference. its a TArray of TSubclass.


UCLASS()
class BBLPNYUTIL_API UAnimationBatchMeta : public UAnimMetaData
{
	GENERATED_BODY()
	
public:

	
	UPROPERTY(EditAnywhere)
	TArray<TSubclassOf<UAnimationBatch> > Inherit;

#if WITH_EDITOR
	UPROPERTY()
	TArray<FAnimationBatchCache> InheritCache;
#endif

	UPROPERTY(EditAnywhere)
	FAnimationBatchConfiguration Overrides;

	UPROPERTY(VisibleAnywhere)
	FAnimationBatchConfiguration Final;

	UPROPERTY(VisibleAnywhere)
	uint8 HasFinal : 1;
	UPROPERTY(VisibleAnywhere)
	uint8 PendingAnimations : 1;

#if WITH_EDITOR
	UPROPERTY(EditAnywhere)
	uint8 ApplyToAnimation : 1;
#endif

	UAnimationBatchMeta(const class FObjectInitializer& ObjectInitializer);
...

Any tips/suggestions would help greatly. I’ll follow up with a post if I manage to determine the issue myself Thanks

Also, after writing this I noticed that maybe I was wrongly iterating and tried the following variants of the foreach loop. none of which compiled.
these 3 result in the same C1001 pointing at the start of the function implementation.


for (const TSubclassOf<UAnimationBatch>& klass : Inherit) {


for (const TSubclassOf<UAnimationBatch> klass : Inherit) {


for (TSubclassOf<UAnimationBatch> klass : Inherit){

this of course didn’t result in the C1001, but a different error because its a const member (so did not compile)


for (TSubclassOf<UAnimationBatch>& klass : Inherit){

then for sanity sake, i switched to a regular old for loop. this also results in the same C1001.


for (int32 i = 0; i < Inherit.Num(); i++) {
	const TSubclassOf<UAnimationBatch>&klass = Inherit*;
	any |= (*klass != nullptr) && klass.GetDefaultObject()->GetConfiguration(o);
}

Yet further… I decided to drop the function call entirely. And i still get the C1001


for (int32 i = 0; i < Inherit.Num(); i++) {
	const TSubclassOf<UAnimationBatch>&klass = Inherit*;
	any |= (*klass != nullptr);
}

when i have it check for the default object it does not compile.


for (int32 i = 0; i < Inherit.Num(); i++) {
	const TSubclassOf<UAnimationBatch>&klass = Inherit*;
	any |= (nullptr != klass.GetDefaultObject());
}

so i moved on to try the UClass * implicit operator , still have C1001


for (int32 i = 0; i < Inherit.Num(); i++) {
	const UClass *klass = Inherit*;
	any |= (klass != nullptr);
}

So i’m planning on swapping out usage of TSubclassOf with plain old UClass* but this will take awhile to test (and is not really ideal from the UI front end POV).

UPDATE:
I did as mentioned above, replaced usage of TSubclassOf with UClass* which was fruitless.

the declaration of Inherit now:


UCLASS()
class BBLPNYUTIL_API UAnimationBatchMeta : public UAnimMetaData
{
	GENERATED_BODY()
	
public:
	UPROPERTY(EditAnywhere)
	TArray<UClass* > Inherit;

#if WITH_EDITOR
	UPROPERTY()
	TArray<FAnimationBatchCache> InheritCache;
#endif

	UPROPERTY(EditAnywhere)
	FAnimationBatchConfiguration Overrides;

	UPROPERTY(VisibleAnywhere)
	FAnimationBatchConfiguration Final;

	UPROPERTY(VisibleAnywhere)
	uint8 HasFinal : 1;
	UPROPERTY(VisibleAnywhere)
	uint8 PendingAnimations : 1;

#if WITH_EDITOR
	UPROPERTY(EditAnywhere)
	uint8 ApplyToAnimation : 1;
#endif

	UAnimationBatchMeta(const class FObjectInitializer& ObjectInitializer);
...

and the function the compiler states is the issue:


bool UAnimationBatchMeta::GatherConfiguration(FAnimationBatchConfiguration & o) const {//<-- C1001

	bool any = false;

	o = FAnimationBatchConfiguration();

	for (int32 i = 0; i < Inherit.Num(); i++) {
		UClass *const &klass = Inherit*;
		any |= klass != nullptr;// && nullptr != Cast<UAnimationBatch>(klass->GetDefaultObject());
	}

	any |= UAnimationBatch::Solidify(Overrides, o);
	return any;
}

Note that if the Cast<> call there is commented out, and still results in a compile error C1001. Again if I comment out the entire for block in the code, it compiles (but it does not do what I intented.)

Again, any tips would be greatly appreciated! I’m going to temporarily retire focus on this issue and stay with Debug Editor builds for now and cross my fingers that I don’t lose assets when I eventually accidentally launch through epic games launcher.

Further info: long before I posted this I searched for what could cause the C1001 specific to UE4, and besides the various answers which were marked as resolved due to inactivity the only other suggestion is that its a CPU issue and can be resolved by not-overclocking your CPU. While I’m hesitant to come to that conclusion, to the best of my knowledge my board is not overclocking the CPU (even though I do have a i7-4960X which is intended to be overclocked). I’ve attached a picture of dxdiag.

Thanks

Hi PatGlynn, I hope these following tips would help you into fixing your C1001 compiler error problem. C1001 is mostly the result of a particular optimization option issue since you’re only having this issue when you try and compile for the development build this is most likely the issue. You could try turning off a number of optimization options for your compiler, I’m assuming you are using Visual Studio 2015, try checking out the documentation on VS2015, looking for optimization options in particular. I’ll post a link below which I hope you find useful.
You could also try updating you compiler because C1001 can be a caused by bugs within the compiler it self and these are usually fixed with regular updates.
Let me know how you get on? I hope you find this useful.

VS2015 optimize link:
https://msdn.microsoft.com/en-us/library/chh3fb0k.aspx

Thanks MichaelDavis!

I appreciate the info, I was aware that it is likely some sort of compiler option but I’d prefer not turning off optimizations. Before making this post I also took the step of updating my VS to the latest to no avail.

If I’m able to figure out what the issue is, or even make some progress I’ll certainly follow up with another post. I’d normally power through the issue myself but the odd thing to me is that the compiler error only happens when doing anything with an array of UClass*/TSubclassOf<> so was hoping since I’ve only been using UE4 for about a month now if there may be something i’m obviously doing wrong or even (with hesitation) a bug with the compiler and or engine.

One thing I will say, since jumping boat from unity / C# for 6+ years back to C++ which I probably used for about 5+ years prior to that its amazing how the language changed and I’ve been using constexpr a lot. I worry that my utilization of the c++11/14 features could be contributing to the issue and for whatever reason is clashing with something in that function.

Anyways, thanks again and while I’ve been ignoring the issue for the past few days by restricting myself to debuggame editor builds its something I’ll ultimately have to address or hope is addressed with an update to compiler or engine.