diff --git a/compiler2/record.c b/compiler2/record.c
index 0a0384c8821574f33c703322ec05e9135f3edc03..82a709dbd0c812e1eb0a3873dfbc1c6599aa3a22 100644
--- a/compiler2/record.c
+++ b/compiler2/record.c
@@ -1942,7 +1942,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
       "      collected_ns = collect_ns(p_td, num_collected, def_ns);\n" /* our own ns */
       "    }\n"
       "    else if ((p_flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1){\n"
-      "      const namespace_t * ns = p_td.my_module->get_ns(p_td.ns_index);\n"
+      "      const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);\n"
       "      if (*ns->px == '\\0') {\n"
       "        collected_ns = Base_Type::collect_ns(p_td, num_collected, def_ns);\n"
       "      }\n"
@@ -1956,7 +1956,7 @@ void gen_xer(const struct_def *sdef, char **pdef, char **psrc)
       "  const boolean empty_ns_hack = e_xer && !omit_tag && (p_indent > 0)\n"
       "    && (p_td.xer_bits & FORM_UNQUALIFIED)\n"
       "    && p_td.my_module && p_td.ns_index != -1\n"
-      "    && *p_td.my_module->get_ns(p_td.ns_index)->px == '\\0';\n"
+      "    && *p_td.my_module->get_ns((size_t)p_td.ns_index)->px == '\\0';\n"
     );
 
     src = mputstr(src, "  boolean delay_close = e_xer");
diff --git a/core/Basetype.cc b/core/Basetype.cc
index 65767be0170d6cca27146cb9543aa373a63eafcd..0576c03d26d335fc6a3174ba46e4c292af00db34 100644
--- a/core/Basetype.cc
+++ b/core/Basetype.cc
@@ -262,7 +262,7 @@ int Base_Type::begin_xml(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
     boolean namespaces_needed = FALSE;
     if (exer) {
       if (p_td.my_module != NULL && p_td.ns_index != -1) {
-        ns_info = p_td.my_module->get_ns(p_td.ns_index);
+        ns_info = p_td.my_module->get_ns((size_t)p_td.ns_index);
       }
 
       namespaces_needed = exer && //!(p_td.xer_bits & FORM_UNQUALIFIED) &&
@@ -1024,7 +1024,7 @@ char ** Base_Type::collect_ns(const XERdescriptor_t& p_td, size_t& num, bool& de
   char *tmp = NULL;
   if (p_td.my_module != 0 && p_td.ns_index != -1
     && !(p_td.xer_bits & FORM_UNQUALIFIED)) {
-    const namespace_t *my_ns = p_td.my_module->get_ns(p_td.ns_index);
+    const namespace_t *my_ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
     if (!*my_ns->px) def_ns = TRUE;
     tmp = mprintf(" xmlns%s%s='%s'",
       ((*my_ns->px) ? ":" : ""), my_ns->px,
diff --git a/core/XER.cc b/core/XER.cc
index e24cf3406d13bfee6d30f4a17e1442f66817cb3e..412ddef89d03307d3e4d89bde5ace3fbd349bada 100644
--- a/core/XER.cc
+++ b/core/XER.cc
@@ -56,7 +56,7 @@ const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int
 
   const namespace_t *expected_ns = 0;
   if (p_td.my_module != 0 && p_td.ns_index != -1) {
-    expected_ns = p_td.my_module->get_ns(p_td.ns_index);
+    expected_ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
   }
 
   if (0 == name) {
@@ -85,7 +85,7 @@ const char* verify_name(XmlReaderWrap& reader, const XERdescriptor_t& p_td, int
       }
       else {
         if (nsuri == 0) { // XML node has no namespace
-          if (p_td.my_module->get_ns(p_td.ns_index)->px[0] != 0) { // and module has namespace prefix
+          if (p_td.my_module->get_ns((size_t)p_td.ns_index)->px[0] != 0) { // and module has namespace prefix
             TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_TAG,
               "Missing namespace '%s'", expected_ns->ns);
           }
@@ -121,7 +121,7 @@ boolean check_namespace(const char *ns_uri, const XERdescriptor_t& p_td)
     return ns_uri==0 || *ns_uri=='\0'; // there should be no ns
   }
   else {
-    const namespace_t *expected_ns = p_td.my_module->get_ns(p_td.ns_index);
+    const namespace_t *expected_ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
     if (ns_uri!=0) return strcmp(ns_uri, expected_ns->ns)==0;
     else return TRUE; // if no namespace we presume it's the expected one
   }
@@ -131,7 +131,7 @@ void write_ns_prefix(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf)
 {
   if (p_td.my_module != 0 && p_td.ns_index != -1
     && !(p_td.xer_bits & FORM_UNQUALIFIED)) {
-    const namespace_t *my_ns = p_td.my_module->get_ns(p_td.ns_index);
+    const namespace_t *my_ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
     if (my_ns->px[0] != 0) { // not an empty prefix
       p_buf.put_s(strlen(my_ns->px), (cbyte*)my_ns->px);
       p_buf.put_c(':');
diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc
index e889ceb2ebf3ebd07800a8ff928b0d10306137bd..a77485d95e69a7a0c73008560c4d5b2c93cb223c 100644
--- a/core2/Basetype2.cc
+++ b/core2/Basetype2.cc
@@ -4168,7 +4168,7 @@ int Record_Type::XER_encode(const XERdescriptor_t& p_td, TTCN_Buffer& p_buf,
       collected_ns = collect_ns(p_td, num_collected, def_ns);
     }
     else if ((flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1) {
-      const namespace_t * ns = p_td.my_module->get_ns(p_td.ns_index);
+      const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
       // The default namespace has been squashed.
       // If we are in the default namespace, restore it.
       if (*ns->px == '\0') {
@@ -4612,7 +4612,7 @@ int Record_Type::XER_encode_negtest(const Erroneous_descriptor_t* p_err_descr,
       collected_ns = collect_ns(p_td, num_collected, def_ns);
     }
     else if ((flavor & DEF_NS_SQUASHED) && p_td.my_module && p_td.ns_index != -1) {
-      const namespace_t * ns = p_td.my_module->get_ns(p_td.ns_index);
+      const namespace_t * ns = p_td.my_module->get_ns((size_t)p_td.ns_index);
       // The default namespace has been squashed.
       // If we are in the default namespace, restore it.
       if (*ns->px == '\0') {