diff --git a/common/pattern_uni.y b/common/pattern_uni.y
index e882a1ce775edee120d1e832af60a6fa9a82b3e1..35940696988f7054704a72bea078482102aa2da6 100644
--- a/common/pattern_uni.y
+++ b/common/pattern_uni.y
@@ -574,10 +574,10 @@ RE_Quadruple:
     if ($3 == 0 && $5 == 0 && $7 == 0 && $9 == 0) TTCN_pattern_error("Zero "
       "character (i.e. quadruple `\\q{0,0,0,0}') is not supported in a "
       "pattern for type universal charstring.");
-    $$.comp.group = $3;
-    $$.comp.plane = $5;
-    $$.comp.row = $7;
-    $$.comp.cell = $9;
+    $$.comp.group = (unsigned char)$3;
+    $$.comp.plane = (unsigned char)$5;
+    $$.comp.row = (unsigned char)$7;
+    $$.comp.cell = (unsigned char)$9;
   }
 ;
 
diff --git a/compiler2/PredefFunc.cc b/compiler2/PredefFunc.cc
index e91ee3f8b0e7d1396de88a2d98ab93b5f01c6ed6..d756b57a542f5a129253ddd15990096556ea855e 100644
--- a/compiler2/PredefFunc.cc
+++ b/compiler2/PredefFunc.cc
@@ -766,7 +766,7 @@ string* remove_bom(const string& encoded_value)
   string str_uppercase(encoded_value);
   size_t enough = length > sizeof(utf32be)-1 ? sizeof(utf32be)-1 : length;
   for (size_t i = 0; i < enough; ++i) {
-    str_uppercase[i] = toupper(encoded_value[i]);
+    str_uppercase[i] = (char)toupper(encoded_value[i]);
   }
 
   if      (str_uppercase.find(utf32be, 0) < length) length_of_BOM = sizeof(utf32be)-1;
@@ -833,7 +833,7 @@ string* get_stringencoding(const string& encoded_value)
   string str_uppercase(encoded_value);
   size_t enough = length > sizeof(utf32be)-1 ? sizeof(utf32be)-1 : length;
   for (size_t i = 0; i < enough; ++i) {
-    str_uppercase[i] = toupper(encoded_value[i]);
+    str_uppercase[i] = (char)toupper(encoded_value[i]);
   }
 
   if      (str_uppercase.find(utf32be, 0) < length) return new string("UTF-32BE");
diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc
index 7f4d575aefe5e65859f7c9995ce69806fb6bd5d8..93239ac46da3a31648e16bc9bb7663c7b46c48e6 100644
--- a/compiler2/Type_chk.cc
+++ b/compiler2/Type_chk.cc
@@ -601,22 +601,22 @@ void change_name(string &name, XerAttributes::NameChange change) {
   case NamespaceSpecification::UPPERCASED:
     // Walking backwards calls size() only once. Loop var must be signed.
     for (int i = name.size()-1; i >= 0; --i) {
-      name[i] = toupper(name[i]);
+      name[i] = (char)toupper(name[i]);
     }
     break;
 
   case NamespaceSpecification::LOWERCASED:
     for (int i = name.size()-1; i >= 0; --i) {
-      name[i] = tolower(name[i]);
+      name[i] = (char)tolower(name[i]);
     }
     break;
 
   case NamespaceSpecification::CAPITALIZED:
-    name[0] = toupper(name[0]);
+    name[0] = (char)toupper(name[0]);
     break;
 
   case NamespaceSpecification::UNCAPITALIZED:
-    name[0] = tolower(name[0]);
+    name[0] = (char)tolower(name[0]);
     break;
 
   default: // explicitly specified name
@@ -778,19 +778,19 @@ void Type::target_of_text(string & text)
 
     switch ((unsigned long)txt.new_text) {
     case NamespaceSpecification::CAPITALIZED: // tARGET -> TARGET
-      target[0] = toupper(target[0]);
+      target[0] = (char)toupper(target[0]);
       break;
     case NamespaceSpecification::UNCAPITALIZED:
-      target[0] = tolower(target[0]); // TARGET -> tARGET
+      target[0] = (char)tolower(target[0]); // TARGET -> tARGET
       break;
     case NamespaceSpecification::UPPERCASED:
       for (int si = target.size() - 1; si >= 0; --si) {
-        target[si] = toupper(target[si]);
+        target[si] = (char)toupper(target[si]);
       }
       break;
     case NamespaceSpecification::LOWERCASED:
       for (int si = target.size() - 1; si >= 0; --si) {
-        target[si] = tolower(target[si]);
+        target[si] = (char)tolower(target[si]);
       }
       break;
 
@@ -2224,9 +2224,9 @@ void Type::chk_xer() { // XERSTUFF semantic check
       char first[5] = {0,0,0,0,0};
       strncpy(first, xerattrib->namespace_.prefix, 4);
       bool xml_start = !memcmp(first, "xml", 3);
-      first[0] = toupper(first[0]);
-      first[1] = toupper(first[1]);
-      first[2] = toupper(first[2]);
+      first[0] = (char)toupper(first[0]);
+      first[1] = (char)toupper(first[1]);
+      first[2] = (char)toupper(first[2]);
       if ((xml_start // It _is_ "xml" or starts with "xml"
         // Or it matches (('X'|'x') ('M'|'m') ('L'|'l'))
         || (first[3] == 0 && !memcmp(first, "XML", 3)))
diff --git a/compiler2/Value.cc b/compiler2/Value.cc
index ef37c9901bade2915270a9d970f343517876983f..cc2e9d45c5c314872492e985b0ec4a929cfee01f 100644
--- a/compiler2/Value.cc
+++ b/compiler2/Value.cc
@@ -9477,7 +9477,7 @@ error:
     if (valuetype != V_CHOICE) FATAL_ERROR("Value::set_alt_name_to_lowercase()");
     string new_name = u.choice.alt_name->get_name();
     if (isupper(new_name[0])) {
-      new_name[0] = tolower(new_name[0]);
+      new_name[0] = (char)tolower(new_name[0]);
       if (new_name[new_name.size() - 1] == '_') {
         // an underscore is inserted at the end of the alternative name if it's
         // a basic type's name (since it would conflict with the class generated
diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc
index 38829cbe7616368978fa5e3b49115535e08504a4..c827a6d008111a7faafc1e62895b40d45fce6209 100644
--- a/compiler2/ttcn3/AST_ttcn3.cc
+++ b/compiler2/ttcn3/AST_ttcn3.cc
@@ -200,7 +200,7 @@ namespace Ttcn {
     if (ref_type != FIELD_REF) FATAL_ERROR("FieldOrArrayRef::set_field_name_to_lowercase()");
     string new_name = u.id->get_name();
     if (isupper(new_name[0])) {
-      new_name[0] = tolower(new_name[0]);
+      new_name[0] = (char)tolower(new_name[0]);
       if (new_name[new_name.size() - 1] == '_') {
         // an underscore is inserted at the end of the field name if it's
         // a basic type's name (since it would conflict with the class generated
diff --git a/compiler2/ttcn3/Templatestuff.cc b/compiler2/ttcn3/Templatestuff.cc
index 3fe276f865aff626414e6c7b1252b7b640a59bbd..1a2d91251fc99157bf8f90063e8dfeee81726b34 100644
--- a/compiler2/ttcn3/Templatestuff.cc
+++ b/compiler2/ttcn3/Templatestuff.cc
@@ -389,7 +389,7 @@ namespace Ttcn {
   {
     string new_name = name->get_name();
     if (isupper(new_name[0])) {
-      new_name[0] = tolower(new_name[0]);
+      new_name[0] = (char)tolower(new_name[0]);
       if (new_name[new_name.size() - 1] == '_') {
         // an underscore is inserted at the end of the alternative name if it's
         // a basic type's name (since it would conflict with the class generated
diff --git a/core/Charstring.cc b/core/Charstring.cc
index 13afe2c2a5e0ef733f9625bce677706f042a2363..f72ce5d72bf57209d89a0f34db74187e7b544300 100644
--- a/core/Charstring.cc
+++ b/core/Charstring.cc
@@ -1017,12 +1017,12 @@ int CHARSTRING::TEXT_decode(const TTCN_Typedescriptor_t& p_td,
     &&  p_td.text->val.parameters->decoding_params.convert != 0) {
     if (p_td.text->val.parameters->decoding_params.convert == 1) {
       for (int a = 0; a < str_len; a++) {
-        val_ptr->chars_ptr[a] = toupper(val_ptr->chars_ptr[a]);
+        val_ptr->chars_ptr[a] = (char)toupper(val_ptr->chars_ptr[a]);
       }
     }
     else {
       for (int a = 0; a < str_len; a++) {
-        val_ptr->chars_ptr[a] = tolower(val_ptr->chars_ptr[a]);
+        val_ptr->chars_ptr[a] = (char)tolower(val_ptr->chars_ptr[a]);
       }
     }
   }
diff --git a/core/Universal_charstring.cc b/core/Universal_charstring.cc
index 19022aa1b847869155d96a1c750f7d89b887790a..dd5b5f2c463094c6b6484010d78f1219fb177e36 100644
--- a/core/Universal_charstring.cc
+++ b/core/Universal_charstring.cc
@@ -1355,12 +1355,12 @@ int UNIVERSAL_CHARSTRING::TEXT_decode(const TTCN_Typedescriptor_t& p_td,
     &&  p_td.text->val.parameters->decoding_params.convert != 0) {
     if (p_td.text->val.parameters->decoding_params.convert == 1) {
       for (int a = 0; a < str_len; a++) {
-        val_ptr->chars_ptr[a] = toupper(val_ptr->chars_ptr[a]);
+        val_ptr->chars_ptr[a] = (char)toupper(val_ptr->chars_ptr[a]);
       }
     }
     else {
       for (int a = 0; a < str_len; a++) {
-        val_ptr->chars_ptr[a] = tolower(val_ptr->chars_ptr[a]);
+        val_ptr->chars_ptr[a] = (char)tolower(val_ptr->chars_ptr[a]);
       }
     }
   }*/