From 9d4a1b24e9ec68243e4b31ad4cc76e6c5b65b344 Mon Sep 17 00:00:00 2001 From: Aaron Muir Hamilton Date: Tue, 24 Oct 2017 10:59:01 +0000 Subject: [PATCH] Preprocessor: Evaluate INT_MIN % -1 to 0. --- Test/cppIntMinOverNegativeOne.frag | 3 +++ glslang/MachineIndependent/preprocessor/Pp.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Test/cppIntMinOverNegativeOne.frag b/Test/cppIntMinOverNegativeOne.frag index 1cdaaeb..b7e0a95 100644 --- a/Test/cppIntMinOverNegativeOne.frag +++ b/Test/cppIntMinOverNegativeOne.frag @@ -1,3 +1,6 @@ #if (-2147483648 / -1) != 0 #error INT_MIN / -1 should yield 0, something went wrong. +#endif +#if (-2147483648 % -1) != 0 +#error INT_MIN % -1 should yield 0, something went wrong. #endif \ No newline at end of file diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 0cb560c..aeb42a0 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -352,7 +352,7 @@ namespace { int op_sub(int a, int b) { return a - b; } int op_mul(int a, int b) { return a * b; } int op_div(int a, int b) { return a == INT_MIN && b == -1 ? 0 : a / b; } - int op_mod(int a, int b) { return a % b; } + int op_mod(int a, int b) { return a == INT_MIN && b == -1 ? 0 : a % b; } int op_pos(int a) { return a; } int op_neg(int a) { return -a; } int op_cmpl(int a) { return ~a; } -- 2.7.4