Summary
A TMap where the key is an FString can be created like so:
TMap<FString, int32> MyMap = { MakeTuple(TEXT("A"), 0) };
This will compile fine. During runtime when the code executes the program will crash.
If you mouse over MakeTuple it is creating a TTuple<const wchar_t*, int32>.
Issue can be solved by changing the code to:
TMap<FString, int32> MyMap = { MakeTuple(FString(TEXT("A")), 0) };
What Type of Bug are you experiencing?
Other
Steps to Reproduce
-
create a new project
-
open project in visual studio. In any of the project’s .cpp files in global scope declare:
static TMap<FString, int32> M = { MakeTuple(TEXT("A"), 0) }; -
close unreal engine
-
compile your code
-
launch the project. The project’s module will fail to load. The error message you receive will be: “The game module ‘MyProject570’ could not be loaded. There may be an operating system error, the module may not be properly set up, or a plugin which has been included into the build has not been turned on.”
Expected Result
Compile-time error. If that isn’t possible then a check being hit would be helpful.
Observed Result
Project module fails to load. Unhelpful error message is shown. Logs are of no help.
Affects Versions
5.7
Platform(s)
Windows
Additional Notes
Tested in 5.7. I did not try 5.8.
Happens whether FString is key or value.
Causes crashes anytime the code is executed. I chose static variable initialization time because that is the most difficult to debug, to show a case that could cause some engine users to lose a lot of time trying to debug.
It would be a good idea to update that error message so that it asks users to check static variable initialization for any errors.