From b91dd7f7529e3d21beebd6c8dc99676b9b23a370 Mon Sep 17 00:00:00 2001 From: Edoardo Lolletti Date: Mon, 15 Apr 2024 22:39:25 +0200 Subject: [PATCH] Assert various warnings when compiling x64 with msvc --- bit.h | 3 ++- function_array_helper.h | 5 ++++- libcard.cpp | 2 +- libduel.cpp | 2 +- libgroup.cpp | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bit.h b/bit.h index efd3db1..bac7d36 100644 --- a/bit.h +++ b/bit.h @@ -22,7 +22,8 @@ constexpr inline uint8_t popcnt(T val) { template constexpr inline bool has_invalid_bits(T value, T2 allowed) { - return (value & (~allowed)) != 0; + using BiggestInt = std::conditional_t<(sizeof(T) > sizeof(T2)), T, T2>; + return (static_cast(value) & (~static_cast(allowed))) != static_cast(0); } } diff --git a/function_array_helper.h b/function_array_helper.h index dc2317f..a1f735f 100644 --- a/function_array_helper.h +++ b/function_array_helper.h @@ -19,7 +19,10 @@ #if !defined(__INTELLISENSE__) || !HAS_COUNTER #include #include -#include +#if HAS_COUNTER +#include //std::conditional_t +#endif +#include //std::index_sequence, std::make_index_sequence #include "common.h" // use forceinline only in release builds diff --git a/libcard.cpp b/libcard.cpp index a8dea1a..272ce36 100644 --- a/libcard.cpp +++ b/libcard.cpp @@ -1791,7 +1791,7 @@ LUA_FUNCTION(GetCounter) { return 1; } LUA_FUNCTION(GetAllCounters) { - lua_createtable(L, self->counters.size(), 0); + lua_createtable(L, static_cast(self->counters.size()), 0); for(const auto& counter : self->counters) { lua_pushinteger(L, counter.first); lua_pushinteger(L, counter.second[0] + counter.second[1]); diff --git a/libduel.cpp b/libduel.cpp index 5dd005f..7f351d3 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -1983,7 +1983,7 @@ LUA_STATIC_FUNCTION(GetChainInfo) { break; case CHAININFO::TRIGGERING_SETCODES: { const auto& setcodes = ch->triggering_state.setcodes; - lua_createtable(L, setcodes.size(), 0); + lua_createtable(L, static_cast(setcodes.size()), 0); int i = 1; for(const auto& setcode : setcodes) { lua_pushinteger(L, i++); diff --git a/libgroup.cpp b/libgroup.cpp index 22c6a3e..f5419c4 100644 --- a/libgroup.cpp +++ b/libgroup.cpp @@ -575,7 +575,7 @@ LUA_FUNCTION(GetClass) { for(auto& pcard : self->container) { er.insert(pduel->lua->get_operation_value(pcard, findex, extraargs)); } - lua_createtable(L, er.size(), 0); + lua_createtable(L, static_cast(er.size()), 0); int i = 1; for(auto& val : er) { lua_pushinteger(L, i++);