[pcre-dev] MSVC (win32) warnings with jit compiler

Top Page
Delete this message
Author: Evgeny Grin
Date:  
To: pcre-dev
Subject: [pcre-dev] MSVC (win32) warnings with jit compiler
HI!

I have two warnings on MSVC 2010 for pcre_jit_compile.c for 2 lines
      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -OVECTOR(0));


"warning C4146: unary minus operator applied to unsigned type, result still unsigned"

I eliminate warnings with simple patch


--- pcre_jit_compile.c.orig    2013-05-10 18:04:21 +0400
+++ pcre_jit_compile.c    2013-08-25 01:16:38 +0400
@@ -481,7 +481,7 @@ to characters. The vector data is divide
 group contains the start / end character pointers, and the second is
 the start pointers when the end of the capturing group has not yet reached. */
 #define OVECTOR_START    (common->ovector_start)
-#define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))
+#define OVECTOR(i)       (OVECTOR_START + (i) * (sljit_sw)sizeof(sljit_sw))
 #define OVECTOR_PRIV(i)  (common->cbra_ptr + (i) * sizeof(sljit_sw))
 #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])



BTW warnings are wrong!
I ran pcre_jit_test compiled with original code and had succes.
Then I just removed minus from code compile it again and pcre_jit_test compiled ended with error.
With my patch test works just fine.

Best Wishes,
Evgeny