From ce7e9d37b3f4948a4479f11df7d80b9e3c11f91c Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 10 Aug 2015 10:51:11 +0100 Subject: [PATCH] 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. --- re2c/src/codegen/scc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- 2.50.1