CommutativeAssociativeBinaryOperator behaviour isn't coherent

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:

  1. create a new blanck c++ project, without content, called “TestCommutativeOp”
  2. Open the project in visual studio, edit “TestCommutativeOpGameMode.h” as shown below.
  3. compile the source code in visual studio (it compiles)
  4. Open the editor, create a new Blueprint with parent class ‘TestCommutativeOpGameMode’, call it “TestGameMode”
  5. Open the blueprint, connect a “PrintString” node to event begin play.
  6. Select “Test/Test” node in the list after clicking with the right mouse button.
  7. connect “OutShape” (the output of the just created node) to “In String” of print string.
  8. Compile and save the Blueprint (it compiles).
  9. Open “Edit/Projects Setting” → “Maps & Modes”, in “Default GameMode” set “TestGameMode”
  10. Run the game in the editor, it works.
  11. Close the editor, return to the project in visual studio.
  12. Click with right mouse button on TestCommutativeOp project, select “Set as Startup Project”
  13. Click with right mouse button on TestCommutativeOp project, select “Properties”
  14. Under “Debugging → Command Arguments”, set " “$(SolutionDir)$(ProjectName).uproject” -game "
  15. Run in debug from visual studio: it crashes trying to recompile the blueprint.


class TESTCOMMUTATIVEOP_API ATestCommutativeOpGameMode : public AGameMode
	UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Test", meta = (Keywords = "max maximum", CommutativeAssociativeBinaryOperator = "true"))
	static void Test(int32 InShape1, int32 InShape2, int32& OutShape, bool Option = false);


#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.


What’s happening here is that an Ensure is being triggered in relation to the call to Test in the blueprint. The editor is designed to process an Ensure then print an output to the editor’s output log and continue running. When Visual Studio reads the ensure it halts process so that you can address the cause immediately.


Thanks for the answer .
Yeah, now i saw the error in the output log, but it can easily slip by unnoticed.
Wouldn’t it be better to have a warning in blueprint compiling?

It’s just a suggestion anyway.