From: Ulya Trofimovich Date: Mon, 10 Aug 2015 09:51:11 +0000 (+0100) Subject: Another explicit cast of pointer difference to uint32_t that seems to be safe. X-Git-Tag: 0.15~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce7e9d37b3f4948a4479f11df7d80b9e3c11f91c;p=re2c Another explicit cast of pointer difference to uint32_t that seems to be safe. In theory, 'top' points at the top of stack and it's value is always greater than or equal to 'stk' that points to stack bottom. Total stack size is equal to 'DFA::nStates', which is of type uint32_t (DFAs larger than 2^32 states are currently not supported an will crash re2c). In practice, 'stk' is not changed and 'top' is only incremented before the cast (it's decremented afterwards. Note that the function is self-recursive). Fixes [-Wconversion] warning. --- diff --git a/re2c/src/codegen/scc.cc b/re2c/src/codegen/scc.cc index 243497a8..c7dea307 100644 --- a/re2c/src/codegen/scc.cc +++ b/re2c/src/codegen/scc.cc @@ -16,7 +16,7 @@ SCC::~SCC () void SCC::traverse (State * x) { *top = x; - uint32_t k = ++top - stk; + const uint32_t k = static_cast (++top - stk); x->depth = k; for (uint32_t i = 0; i < x->go.nSpans; ++i)