Compiler Warning fixes
MODIFY
src/lcf/dbarray.h
src/lcf/dbarray.h
@@ -29,6 +29,7 @@ class DBArray {
public:
using value_type = T;
using size_type = DBArrayAlloc::size_type;
+ using ssize_type = typename std::make_signed<size_type>::type;
using iterator = T*;
using const_iterator = const T*;
@@ -49,7 +50,7 @@ class DBArray {
std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<Iter>::iterator_category>::value, int>::type = 0
>
DBArray(Iter first, Iter last) {
- construct(std::distance(first, last), [&](void* p) { new (p) T(*first); ++first; });
+ construct(static_cast<size_type>(std::distance(first, last)), [&](void* p) { new (p) T(*first); ++first; });
}
DBArray(std::initializer_list<T> ilist)
@@ -102,7 +103,7 @@ class DBArray {
private:
T* alloc(size_t count) {
- return reinterpret_cast<T*>(DBArrayAlloc::alloc(count * sizeof(T), count, alignof(T)));
+ return reinterpret_cast<T*>(DBArrayAlloc::alloc(static_cast<size_type>(count * sizeof(T)), static_cast<size_type>(count), static_cast<size_type>(alignof(T))));
}
void free(void* p) {

MODIFY
src/lcf/dbarrayalloc.h
src/lcf/dbarrayalloc.h
@@ -21,6 +21,7 @@ namespace lcf {
struct DBArrayAlloc {
using size_type = uint32_t;
+ using ssize_type = int32_t;
static void* alloc(size_type size, size_type field_size, size_type align);
static void free(void* p, size_type align) noexcept;

MODIFY
src/lcf/dbbitarray.h
src/lcf/dbbitarray.h
#include <algorithm>
#include <type_traits>
-#include "lcf/dbarray.h"
+#include "lcf/dbarrayalloc.h"
namespace lcf {
class DBBitProxy {
public:
using size_type = DBArrayAlloc::size_type;
+ using ssize_type = DBArrayAlloc::ssize_type;
constexpr DBBitProxy() = default;
@@ -32,7 +33,7 @@ class DBBitProxy {
DBBitProxy& operator=(bool x) noexcept {
auto& byte = _base[_idx / CHAR_BIT];
auto bit = _idx % CHAR_BIT;
- byte ^= (-size_type(x) ^ byte) & (size_type(1) << bit);
+ byte ^= (size_type(-ssize_type(x)) ^ byte) & (size_type(1) << bit);
return *this;
}
@@ -67,7 +68,7 @@ template <typename ProxyType>
class DBBitProxyIterator {
public:
using size_type = typename DBBitProxy::size_type;
- using ssize_type = typename std::make_signed<size_type>::type;
+ using ssize_type = DBArrayAlloc::ssize_type;
using difference_type = ssize_type;
using value_type = ProxyType;
@@ -113,6 +114,7 @@ class DBBitArray {
public:
using value_type = bool;
using size_type = DBArrayAlloc::size_type;
+ using ssize_type = typename std::make_signed<size_type>::type;
using iterator = DBBitProxyIterator<DBBitProxy>;
using const_iterator = DBBitProxyIterator<const DBBitProxy>;
@@ -128,7 +130,7 @@ class DBBitArray {
typename std::enable_if<
std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<Iter>::iterator_category>::value, int>::type = 0
>
- DBBitArray(Iter first, Iter last) : _storage(this->alloc(std::distance(first, last))) {
+ DBBitArray(Iter first, Iter last) : _storage(this->alloc(static_cast<size_type>(std::distance(first, last)))) {
std::copy(first, last, begin());
}

MODIFY
src/lcf/dbstring.h
src/lcf/dbstring.h
@@ -30,6 +30,7 @@ class DBString {
public:
using value_type = char;
using size_type = uint32_t;
+ using ssize_type = typename std::make_signed<size_type>::type;
using char_type = value_type; // <- FIXME: HACK to workaround bug in older versions of fmtlib for Player: https://github.com/fmtlib/fmt/issues/1539
using traits_type = std::char_traits<char>;
@@ -104,7 +105,7 @@ class DBString {
private:
char* alloc(size_t count) {
- return reinterpret_cast<char*>(DBArrayAlloc::alloc(count + 1, count, 1));
+ return reinterpret_cast<char*>(DBArrayAlloc::alloc(static_cast<size_type>(count + 1), static_cast<size_type>(count), 1));
}
void free(void* p) {
DBArrayAlloc::free(p, 1);

MODIFY
src/reader_struct.h
src/reader_struct.h
@@ -357,6 +357,7 @@ struct Primitive<DBBitArray> {
stream.Write(ref);
}
static int LcfSize(const DBBitArray& ref, LcfWriter& stream) {
+ (void)stream;
return ref.size();
}
static void WriteXml(const DBBitArray& ref, XmlWriter& stream) {

Compiler Warning fixes