From: Ulya Trofimovich Date: Mon, 10 Aug 2015 09:32:31 +0000 (+0100) Subject: Explicit cast of pointer difference to uint32_t: it seems to be safe from the code. X-Git-Tag: 0.15~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46c5baeae0d3b23f6c2468905a009dd18efd0e11;p=re2c Explicit cast of pointer difference to uint32_t: it seems to be safe from the code. In theory, this function returns the number of 'Span's in the newly constructed 'Span' array, so it must be a non-negative integer number that fits into 32 bits and the cast is safe. In practice, 'x0' variable stays unchanged in this function, while 'x' variable's value can only increase: whenever it can be (conditionally) decremented, it is always unconditionally incremented. So 'x - x0' must be non-negative. Fixes [-Wconversion] warning. --- diff --git a/re2c/src/codegen/prepare_dfa.cc b/re2c/src/codegen/prepare_dfa.cc index cc9b197a..7822d285 100644 --- a/re2c/src/codegen/prepare_dfa.cc +++ b/re2c/src/codegen/prepare_dfa.cc @@ -76,7 +76,7 @@ static uint32_t merge(Span *x0, State *fg, State *bg) if (nf == 0 && nb == 0) { - return x - x0; + return static_cast (x - x0); } }