I’ve just submitted a PR for improving the range-based solver for CSA.
And in the solver-related tests we have a bunch of explicit void casts at the end.
The intent is to keep constraints artificially alive by explicitly mentioning variables tied to those constraints.
This isn’t too realistic, and it should just work without those void-casts.
Like in my PR, I also had a void cast:
void gh_62215(int x, int y, int z) {
if (x != y) return; // x == y
if (z <= x) return; // z > x
if (z >= y) return; // z < y
clang_analyzer_warnIfReached(); // no-warning: This should be dead code.
(void)(x + y + z); // keep the constraints alive.
}
However, if I’d remove that void-cast, the statement would be surprisingly reachable.
It is because if a member is alive in an eqclass, that won’t prevent the rest of the symbols being garbage-collected.
Consequently, after the if (z <= x) return;
, x
gets garbage-collected and we lose x == y
and z > x
constraints; so when we encounter if (z >= y) return;
, we have basically an empty constraints map with an empty eqclass mapping.
This eager garbage-collection problem and losing constraints is directly tied back to #60836, and why we have a bunch of void-casts in the tests artificially keeping such constraints alive.
Do you agree that it shouldn’t affect the analysis weather there is a void-cast at the end or not. The exploded graph should look exactly the same regardless.
@NoQ @Xazax-hun @DonatNagyE
Note that the example would behave as described, if the mentioned PR is applied; but there are other examples in the test suite already.