Calling wrong overload of function

I’m pretty sure that this isn’t supposed to happen at all, but I was able to declare multiple UFunctions in a class with the same name. When I tried to call one of them from C++ it called the other which caused a crash. Since you normally get an error when you try to overload UFunctions, I guess this is just an edge case that hasn’t been found/fixed yet.

I first declared a base class with a BlueprintNativeEvent in it

UCLASS()
class OVERLOADTEST_API ABaseClass : public AActor
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintNativeEvent, Category = "Default")
	void Initialize();

	virtual void Initialize_Implementation();
};

Then I inherited from that class and declared a BlueprintCallable function of the same name as the BlueprintNativeEvent

UCLASS()
class OVERLOADTEST_API AInheritedClass : public ABaseClass
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintCallable, Category = "Default")
	void Initialize(int32 num);
	
	virtual void Initialize_Implementation() override;
};

When I try to call Initialize() from C++, it instead tries to call Initialize(num) and crashes when it tries to copy the parameters (which are null for the function with no parameters).

Attached is a repro case for this bug.

I’m pretty sure UFunctions are looked up by name only and therefore cannot be overloaded at this time. UHT will error out you if you try to overload a function in the same class. It should probably be an error in sub-classes as well.

Hey,

UFunctions can’t be overloaded, and we do test for that - however this is a case of function hiding and it seems we don’t test for that (i.e. a change in signature to an existing function). I’ll file a ticket to get it fixed. Thanks for reporting it!

Steve