Assert various warnings when compiling x64 with msvc

This commit is contained in:
Edoardo Lolletti 2024-04-15 22:39:25 +02:00
parent b47594cecc
commit b91dd7f752
5 changed files with 9 additions and 5 deletions

3
bit.h
View file

@ -22,7 +22,8 @@ constexpr inline uint8_t popcnt(T val) {
template<typename T, typename T2>
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<BiggestInt>(value) & (~static_cast<BiggestInt>(allowed))) != static_cast<BiggestInt>(0);
}
}

View file

@ -19,7 +19,10 @@
#if !defined(__INTELLISENSE__) || !HAS_COUNTER
#include <array>
#include <lauxlib.h>
#include <type_traits>
#if HAS_COUNTER
#include <type_traits> //std::conditional_t
#endif
#include <utility> //std::index_sequence, std::make_index_sequence
#include "common.h"
// use forceinline only in release builds

View file

@ -1791,7 +1791,7 @@ LUA_FUNCTION(GetCounter) {
return 1;
}
LUA_FUNCTION(GetAllCounters) {
lua_createtable(L, self->counters.size(), 0);
lua_createtable(L, static_cast<int>(self->counters.size()), 0);
for(const auto& counter : self->counters) {
lua_pushinteger(L, counter.first);
lua_pushinteger(L, counter.second[0] + counter.second[1]);

View file

@ -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<int>(setcodes.size()), 0);
int i = 1;
for(const auto& setcode : setcodes) {
lua_pushinteger(L, i++);

View file

@ -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<int>(er.size()), 0);
int i = 1;
for(auto& val : er) {
lua_pushinteger(L, i++);