From 8927393baa40b630f353b8fc0a0b29e1f7c9c795 Mon Sep 17 00:00:00 2001 From: Andrew Barnert Date: Wed, 24 Jul 2019 12:23:28 -0700 Subject: [PATCH] Fixes warnings/errors for 32-bit (and maybe ILP64?) builds BugFix: ARM32, and possibly other archs, fails with -Werror The code implicitly casts a uint64_t to a vector::size_type. It does so only after checking bounds (against a value that must have come from a size_type, and without using signed types anywhere), so it should be safe, but it still causes warnings. --- containers.cpp | 3 ++- containers.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/containers.cpp b/containers.cpp index de66891..474cc26 100644 --- a/containers.cpp +++ b/containers.cpp @@ -79,7 +79,8 @@ packToken TokenList::default_constructor(TokenMap scope) { packToken* TokenList::ListIterator::next() { if (i < list->size()) { - return &list->at(i++); + TokenList_t::size_type idx = TokenList_t::size_type(i++); + return &list->at(idx); } else { i = 0; return NULL; diff --git a/containers.h b/containers.h index 7b2adf8..499028b 100644 --- a/containers.h +++ b/containers.h @@ -166,7 +166,8 @@ struct TokenList : public Container, public Iterable { if (list().size() <= idx) { throw std::out_of_range("List index out of range!"); } - return list()[idx]; + TokenList_t::size_type i = TokenList_t::size_type(idx); + return list()[i]; } void push(packToken val) const { list().push_back(val); }