From b3bda71c6d3f04652a4de04b9d1aca5314355d76 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Sep 2025 12:55:54 +0100 Subject: [PATCH 1/2] [cppia] Fix int overflow in arithmetic assignments Currently, the cppia interp runtime uses float operations for arithmetic assignments such as *=. This results in inconsistent int overflow behaviour. --- src/hx/cppia/Cppia.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hx/cppia/Cppia.h b/src/hx/cppia/Cppia.h index b8361537c..0137f2937 100644 --- a/src/hx/cppia/Cppia.h +++ b/src/hx/cppia/Cppia.h @@ -1083,6 +1083,14 @@ struct NAME \ ioVal = left OP f; \ return ioVal; \ } \ + inline static int &run(int &ioVal, hx::CppiaCtx *ctx, hx::CppiaExpr *value) \ + { \ + int left = ioVal; \ + int i = value->runInt(ctx); \ + BCR_CHECK_RET(ioVal); \ + ioVal = left OP i; \ + return ioVal; \ + } \ static bool run(bool &ioVal, hx::CppiaCtx *ctx, hx::CppiaExpr *value) { value->runVoid(ctx); return ioVal; } \ static String run(String &ioVal, hx::CppiaCtx *ctx, hx::CppiaExpr *value) { value->runVoid(ctx); return ioVal; } \ static hx::Object *run(hx::Object * &ioVal, hx::CppiaCtx *ctx, hx::CppiaExpr *value) \ From 54ced669c56156c38f3711fe05481c45b6c29eee Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 17 Sep 2025 12:56:25 +0100 Subject: [PATCH 2/2] [tests] Add regression test for int *= overflow --- test/cppia/Client.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/cppia/Client.hx b/test/cppia/Client.hx index 8b1bf020b..65d193a8a 100644 --- a/test/cppia/Client.hx +++ b/test/cppia/Client.hx @@ -197,6 +197,14 @@ class Client return; } + // regression test for #1257 + var x = 1290555; + x *= 1290555; + if (x != -915102823) { + Common.status = 'Failed regression test for #1257. x: $x'; + return; + } + final extending = new ClientExtendedExtendedRoot(); extending.addValue();