@@ -34,10 +34,10 @@ namespace cmcpp
3434 auto encoded = cx.convert (&cx.opts .memory [ptr], worst_case_size, src, src_byte_len, src_encoding, Encoding::Utf8);
3535 if (worst_case_size > encoded.second )
3636 {
37- ptr = cx.opts .realloc (ptr, worst_case_size, 1 , encoded.second );
37+ ptr = cx.opts .realloc (ptr, worst_case_size, 1 , static_cast < uint32_t >( encoded.second ) );
3838 assert (ptr + encoded.second <= cx.opts .memory .size ());
3939 }
40- return std::make_pair (ptr, encoded.second );
40+ return std::make_pair (ptr, static_cast < uint32_t >( encoded.second ) );
4141 }
4242
4343 inline std::pair<uint32_t , uint32_t > store_utf16_to_utf8 (LiftLowerContext &cx, const void *src, uint32_t src_code_units)
@@ -62,7 +62,7 @@ namespace cmcpp
6262 auto encoded = cx.convert (&cx.opts .memory [ptr], worst_case_size, src, src_code_units, Encoding::Utf8, Encoding::Utf16);
6363 if (encoded.second < worst_case_size)
6464 {
65- ptr = cx.opts .realloc (ptr, worst_case_size, 2 , encoded.second );
65+ ptr = cx.opts .realloc (ptr, worst_case_size, 2 , static_cast < uint32_t >( encoded.second ) );
6666 assert (ptr == align_to (ptr, 2 ));
6767 assert (ptr + encoded.second <= cx.opts .memory .size ());
6868 }
@@ -103,7 +103,7 @@ namespace cmcpp
103103 const size_t src_byte_length = src_code_units * ValTrait<T>::char_size;
104104
105105 assert (src_code_units <= MAX_STRING_BYTE_LENGTH);
106- uint32_t ptr = cx.opts .realloc (0 , 0 , 2 , src_byte_length);
106+ uint32_t ptr = cx.opts .realloc (0 , 0 , 2 , static_cast < uint32_t >( src_byte_length) );
107107 trap_if (cx, ptr != align_to (ptr, 2 ));
108108 trap_if (cx, ptr + src_code_units > cx.opts .memory .size ());
109109 uint32_t dst_byte_length = 0 ;
@@ -118,9 +118,9 @@ namespace cmcpp
118118 else
119119 {
120120 // If it doesn't, convert it to a UTF-16 sequence
121- uint32_t worst_case_size = 2 * src_code_units;
121+ uint32_t worst_case_size = static_cast < uint32_t >( 2 * src_code_units) ;
122122 trap_if (cx, worst_case_size > MAX_STRING_BYTE_LENGTH, " Worst case size exceeds maximum string byte length" );
123- ptr = cx.opts .realloc (ptr, src_byte_length, 2 , worst_case_size);
123+ ptr = cx.opts .realloc (ptr, static_cast < uint32_t >( src_byte_length) , 2 , worst_case_size);
124124 trap_if (cx, ptr != align_to (ptr, 2 ), " Pointer misaligned" );
125125 trap_if (cx, ptr + worst_case_size > cx.opts .memory .size (), " Out of bounds access" );
126126
@@ -147,7 +147,7 @@ namespace cmcpp
147147 uint32_t destPtr = ptr + (2 * dst_byte_length);
148148 uint32_t destLen = worst_case_size - (2 * dst_byte_length);
149149 void *srcPtr = (char *)src + dst_byte_length * ValTrait<T>::char_size;
150- uint32_t srcLen = ( src_code_units - dst_byte_length) * ValTrait<T>::char_size;
150+ uint32_t srcLen = static_cast < uint32_t >(( src_code_units - dst_byte_length) * ValTrait<T>::char_size) ;
151151 auto encoded = cx.convert (&cx.opts .memory [destPtr], destLen, srcPtr, srcLen, src_encoding, Encoding::Utf16);
152152
153153 // Add special tag to indicate the string is a UTF-16 string ---
@@ -158,7 +158,7 @@ namespace cmcpp
158158 }
159159 if (dst_byte_length < src_code_units)
160160 {
161- ptr = cx.opts .realloc (ptr, src_code_units, 2 , dst_byte_length);
161+ ptr = cx.opts .realloc (ptr, static_cast < uint32_t >( src_code_units) , 2 , dst_byte_length);
162162 trap_if (cx, ptr != align_to (ptr, 2 ), " Pointer misaligned" );
163163 trap_if (cx, ptr + dst_byte_length > cx.opts .memory .size (), " Out of bounds access" );
164164 }
@@ -179,18 +179,18 @@ namespace cmcpp
179179 if (src_tagged_code_units & UTF16_TAG)
180180 {
181181 src_simple_encoding = Encoding::Utf16;
182- src_code_units = src_tagged_code_units ^ UTF16_TAG;
182+ src_code_units = static_cast < uint32_t >( src_tagged_code_units ^ UTF16_TAG) ;
183183 }
184184 else
185185 {
186186 src_simple_encoding = Encoding::Latin1;
187- src_code_units = src_tagged_code_units;
187+ src_code_units = static_cast < uint32_t >( src_tagged_code_units) ;
188188 }
189189 }
190190 else
191191 {
192192 src_simple_encoding = src_encoding;
193- src_code_units = src_tagged_code_units;
193+ src_code_units = static_cast < uint32_t >( src_tagged_code_units) ;
194194 }
195195
196196 switch (cx.opts .string_encoding )
@@ -300,7 +300,7 @@ namespace cmcpp
300300 retVal.encoding = encoding;
301301 }
302302 retVal.resize (host_byte_length);
303- auto decoded = cx.convert (retVal.data (), host_byte_length, (void *)&cx.opts .memory [ptr], byte_length, encoding, ValTrait<T>::encoding == Encoding::Latin1_Utf16 ? encoding : ValTrait<T>::encoding);
303+ auto decoded = cx.convert (retVal.data (), host_byte_length, (void *)&cx.opts .memory [ptr], static_cast < uint32_t >( byte_length) , encoding, ValTrait<T>::encoding == Encoding::Latin1_Utf16 ? encoding : ValTrait<T>::encoding);
304304 if ((decoded.second / char_size) < host_byte_length)
305305 {
306306 retVal.resize (decoded.second / char_size);
0 commit comments