Skip to content

Commit c87ac20

Browse files
committed
Fix mixed platform disagreement
1 parent 2ca8a6e commit c87ac20

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

include/boost/decimal/cstdio.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ inline void make_uppercase(char* first, const char* last) noexcept
164164
}
165165
}
166166

167+
// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit
168+
#if defined(__GNUC__) && defined(__i386__)
169+
# pragma GCC diagnostic push
170+
# pragma GCC diagnostic ignored "-Wuseless-cast"
171+
#endif
172+
167173
template <typename... T>
168174
inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char* format, const T... values) noexcept
169175
#ifndef BOOST_DECIMAL_HAS_CONCEPTS
@@ -247,9 +253,13 @@ inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char*
247253
}
248254

249255
*buffer = '\0';
250-
return (buffer - buffer_begin);
256+
return static_cast<int>(buffer - buffer_begin);
251257
}
252258

259+
#if defined(__GNUC__) && defined(__i386__)
260+
# pragma GCC diagnostic pop
261+
#endif
262+
253263
} // namespace detail
254264

255265
template <typename... T>

include/boost/decimal/detail/locale_conversion.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ inline void convert_string_to_c_locale(char* buffer) noexcept
8787
convert_string_to_c_locale(buffer, std::locale());
8888
}
8989

90+
// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit
91+
#if defined(__GNUC__) && defined(__i386__)
92+
# pragma GCC diagnostic push
93+
# pragma GCC diagnostic ignored "-Wuseless-cast"
94+
#endif
95+
9096
inline int convert_pointer_pair_to_local_locale(char* first, const char* last, const std::locale& loc) noexcept
9197
{
9298
const std::numpunct<char>& np = std::use_facet<std::numpunct<char>>(loc);
@@ -136,7 +142,7 @@ inline int convert_pointer_pair_to_local_locale(char* first, const char* last, c
136142
{
137143
if (int_digits > grouping_size)
138144
{
139-
num_separators = (int_digits - 1) / grouping_size;
145+
num_separators = static_cast<int>((int_digits - 1) / grouping_size);
140146
}
141147
}
142148

@@ -186,6 +192,11 @@ inline int convert_pointer_pair_to_local_locale(char* first, const char* last, c
186192
return num_separators;
187193
}
188194

195+
// Cast of return value avoids warning when sizeof(std::ptrdiff_t) > sizeof(int) e.g. when not in 32-bit
196+
#if defined(__GNUC__) && defined(__i386__)
197+
# pragma GCC diagnostic pop
198+
#endif
199+
189200
#if defined(__GNUC__) && __GNUC__ == 9
190201
# pragma GCC diagnostic pop
191202
#elif defined(__clang__) && __clang_major__ == 12

include/boost/decimal/detail/to_chars_integer_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ constexpr char* decompose32(std::uint32_t value, char* buffer) noexcept
127127

128128
for (std::size_t i {}; i < 10; i += 2)
129129
{
130-
boost::decimal::detail::memcpy(buffer + i, radix_table + static_cast<std::size_t>(y >> 57) * 2, 2);
130+
boost::decimal::detail::memcpy(buffer + i, radix_table + (y >> 57) * 2, 2);
131131
y &= mask;
132132
y *= 100U;
133133
}

0 commit comments

Comments
 (0)