diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 208bdcedae98238cd00efdd534f9ec167f849fe3..5f77287e1dd0d922a83489fd51ad1e18f056358f 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -967,7 +967,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
     *is_null= item->null_value;
   }
   if (*is_null)
-    return ~(ulonglong) -1;
+    return ~(ulonglong) 0;
   /*
     Convert strings to the integer DATE/DATETIME representation.
     Even if both dates provided in strings we can't compare them directly as
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index b548550ef54c4d0b9f1fb4e15d766a0589d42d73..4f4083d9b8fc91c3aaed5cd2a110a34d10a09be5 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -164,7 +164,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const
     break;
   }
   default:
-    length= ~(uint32) -1;
+    length= ~(uint32) 0;
   }
   return length;
 }