Description

Attempting to return a const pointer from a UFUNCTION will cause a VS compile error

The syntax

UFUNCTION(BlueprintCallable, Category = test)
const UMyActorComp* SomeFunc();

returns a VS compile error (@ GENERATED_BODY line) stating

Cannot convert from 'const UMyActorComp*' to 'UMyActorComp*'

This is likely related to UE-45717

Steps to Reproduce
  1. Open UE4 Editor (any project)
  2. Add code to project based on Actor (MyActor)
  3. Add the following to MyActor.h
    UFUNCTION(BlueprintCallable, Category = test)
    const UStaticMeshComponent* SomeFunc();
    
  4. Add the following to MyActor.cpp
    const UStaticMeshComponent* AMyActor::SomeFunc()
    {
    	UStaticMeshComponent* Something;
    	return Something;
    }
    
  5. Compile

Result:
Compile fails with error mentioned in description

Expected:
Class compiles and UHT returns a const pointer

Have Comments or More Details?

There's no existing public thread on this issue, so head over toAnswerHub just mention UE-50745 in the post.

8
Login to Vote

Backlogged
ComponentCore - UnrealHeaderTool
Affects Versions4.17.24.18
CreatedOct 4, 2017
UpdatedNov 10, 2019