UE5.1 to 5.3: Large Struct used to hold data is complaining about STRUCT_OFFSET conversion error.

Hi, I have implemented a slightly large nested struct which holds a primary dataset that I use to modify my actors with that I want to display. When trying to convert from UE5.1 to UE5.3 I get a conversion error:

/Users/…/BlueprintInterfaceLibrary.gen.cpp:1712:288: error: implicit conversion from ‘unsigned long’ to ‘uint16’ (aka ‘unsigned short’) changes value from 83088 to 17552 [-Werror,-Wconstant-conversion]
const UECodeGen_Private::FStructPropertyParams Z_Construct_UScriptStruct_FACabStruct_Statics::NewProp_cab_6 = { “cab_6”, nullptr, (EPropertyFlags)0x0010000000000005, UECodeGen_Private::EPropertyGenFlags::Struct, RF_Public|RF_Transient|RF_MarkAsNative, nullptr, nullptr, 1, STRUCT_OFFSET(FACabStruct, cab_6), Z_Construct_UScriptStruct_FACabStruct, METADATA_PARAMS(UE_ARRAY_COUNT(Z_Construct_UScriptStruct_FACabStruct_Statics::NewProp_cab_6_MetaData), Z_Construct_UScriptStruct_FACabStruct_Statics::NewProp_cab_6_MetaData) }; // 2978280576
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Shared/Epic Games/UE_5.3/Engine/Source/Runtime/Core/Public/Templates/UnrealTemplate.h:201:40: note: expanded from macro ‘STRUCT_OFFSET’
#define STRUCT_OFFSET( struc, member ) __builtin_offsetof(struc, member)

This worked in 5.1 and at the same time, the UnrealTemplate engine code seems to be untouched for quite some time. So I don’t think this is a new error introduced, but something that bubbled up.
At the same time this falls back to the __clang implementation of __buildin_offsetof(struc,member), which might be part of the issue.

This happens both when trying to convert the project (as in loading the UE5.1 project from UE5.3) and when generating a new UE5.3 project, copying the code in, and modifying it to the extent that all other compiler errors are gone.

The reason why it is a static nested struct is that I used to read this from a json file where FJsonObjectConverter::JsonObjectToUStruct requires such struct.

Any recommendations?

Same problem different context, see Upgrade [5.2 -> 5.3]: warning C4305: 'initializing': truncation from 'size_t' to 'uint16' - #2 by UnrealEverything

Thank you,
that gives me a nudge in the right direction.
As I am planning to move away from the JSON file and ingest the data via different means, I will rewrite the struct.
This should do the trick even though I hoped there was an easier way to do this for my prototype, as the conversion via JsonObjectToUStruct was quite convenient when functional.
The only downside is now that I will have to rewrite my constructors and deal with memory management a bit.

It would be great to have a remark somewhere that this limitation exists and if larger structures are used give a recommendation.
Finding the issue was not super straightforward, as it was triggered by the version change.

Thanks,
-M

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.