]> granicus.if.org Git - re2c/commitdiff
Explicit cast of pointer difference to uint32_t: it seems to be safe from the code.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 09:32:31 +0000 (10:32 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 09:44:42 +0000 (10:44 +0100)
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.

re2c/src/codegen/prepare_dfa.cc

index cc9b197aa638b22b9fd69183d8032b67355fc76d..7822d285ee0676ed0be35dded2ee5424165d13f0 100644 (file)
@@ -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<uint32_t> (x - x0);
                        }
                }