Description

UHT does not correctly create generated code for BlueprintNativeEvent UFUNCTIONs in an interface that return const values. In the corresponding .gen.cpp file, the generated code does not include the const keyword for the return type, resulting in a build failure due to different type modifiers on the function.

REGRESSION:
No.

Steps to Reproduce
  1. Create a new Basic Code project.
  2. Add a new code interface class to the project.
  3. Add the following function signature to the interface header file:
    public:
    	UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
    	const float TestMethod() const;
    
  4. Add the following function definition to the interface source file:
    const float IMyInterface::TestMethod_Implementation() const
    {
    	const float TestVar = 42.f;
    	return TestVar;
    }
    
    • Note that this definition is not necessary in version 4.20 and later.
  5. Build the project in Visual Studio.

RESULT:
The build will fail with the following error: error C2373: 'IMyInterface::TestMethod': redefinition; different type modifiers

EXPECTED:
The build completes successfully

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-62943 in the post.

2
Login to Vote

Fixed
ComponentUE - Foundation - Core
Affects Versions4.18.34.19.24.20.14.21
Target Fix4.22
Fix Commit4615192
Main Commit4772220
Release Commit4862694
CreatedAug 15, 2018
ResolvedNov 30, 2018
UpdatedFeb 12, 2019
Pull Requests
4995 - GlassBeaver