diff --git a/tccgen.c b/tccgen.c
index 73680300..765e7425 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -934,7 +934,7 @@ static void vset_VT_JMP(void)
         /* we need to jump to 'mov $0,%R' or 'mov $1,%R' */
         int inv = op & (op < 2); /* small optimization */
         vseti(VT_JMP+inv, gvtst(inv, 0));
-        vtop->type.t = origt;
+        vtop->type.t |= origt & (VT_UNSIGNED | VT_DEFSIGN);
     } else {
         /* otherwise convert flags (rsp. 0/1) to register */
         vtop->c.i = op;
diff --git a/tests/tcctest.c b/tests/tcctest.c
index 29f88bd4..5db044d8 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -1220,6 +1220,13 @@ static unsigned int calc_vm_flags(unsigned int prot)
   return prot_bits;
 }
 
+enum cast_enum { FIRST, LAST };
+
+static void tst_cast(enum cast_enum ce)
+{
+    printf("%d\n", ce);
+}
+
 void bool_test()
 {
     int *s, a, b, t, f, i;
@@ -1268,6 +1275,7 @@ void bool_test()
     /* check that types of casted &&/|| are preserved (here the unsignedness) */
     t = 1;
     printf("type of bool: %d\n", (int) ( (~ ((unsigned int) (t && 1))) / 2) );
+    tst_cast(t >= 0 ? FIRST : LAST);
 
     printf("type of cond: %d\n", (~(t ? 0U : (unsigned int)0)) / 2 );
     /* test ? : cast */