DecRef needs to be the last use of its source, since it might destruct it. In the new test case, the second cast expression was reusing the result of the first (through CSE) after it had been DecReffed and destroyed.