Behaviour: a malformed function declared as “CommutativeAssociativeBinaryOperator” is compiled in source code, can be accessed and used successfully in blueprints and the blueprint compiles, and the game can be run in the editor.
However the game crashes if lanched in visual studio.
Expected behaviour an error thrown compiling the source code, or at least an error compiling the blueprint in editor.
Steps to reproduce:
- create a new blanck c++ project, without content, called “TestCommutativeOp”
- Open the project in visual studio, edit “TestCommutativeOpGameMode.h” as shown below.
- compile the source code in visual studio (it compiles)
- Open the editor, create a new Blueprint with parent class ‘TestCommutativeOpGameMode’, call it “TestGameMode”
- Open the blueprint, connect a “PrintString” node to event begin play.
- Select “Test/Test” node in the list after clicking with the right mouse button.
- connect “OutShape” (the output of the just created node) to “In String” of print string.
- Compile and save the Blueprint (it compiles).
- Open “Edit/Projects Setting” → “Maps & Modes”, in “Default GameMode” set “TestGameMode”
- Run the game in the editor, it works.
- Close the editor, return to the project in visual studio.
- Click with right mouse button on TestCommutativeOp project, select “Set as Startup Project”
- Click with right mouse button on TestCommutativeOp project, select “Properties”
- Under “Debugging → Command Arguments”, set " “$(SolutionDir)$(ProjectName).uproject” -game "
- Run in debug from visual studio: it crashes trying to recompile the blueprint.
TestCommutativeOpGameMode.h:
UCLASS()
class TESTCOMMUTATIVEOP_API ATestCommutativeOpGameMode : public AGameMode
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Test", meta = (Keywords = "max maximum", CommutativeAssociativeBinaryOperator = "true"))
static void Test(int32 InShape1, int32 InShape2, int32& OutShape, bool Option = false);
};
TestCommutativeOpGameMode.cpp
#include "TestCommutativeOp.h"
#include "TestCommutativeOpGameMode.h"
void ATestCommutativeOpGameMode::Test(int32 InShape1, int32 InShape2, int32& OutShape, bool Option)
{
OutShape = InShape1 + InShape2;
}
Description and toughts: Since CommutativeAssociativeBinaryOperator is expecting that input and outputs are of the same type (and that there are only 2 inputs too), it’s normal that it crashes.
The problem is that it still compiles and runs normally in the editor, and that’s the strange part.