You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
… out-of-scope variable. (#1031)
* Fix for the crash during CFG construction when CFGLifetimeEnds elements are added to the CFG.
* Make VariableOccurrenceCount take a ValueDecl rather than DeclRefExpr argument
* Removing checked pointers that are no longer in scope from ObservedBounds.
Also removing expressions that refer to out-of-scope variables from AvailableExpressions.
* Added a test case to test the modifications to equivalent expressions
when variables go out of scope within a basic block.
* Fix for a crash on Windows caused by an iterator access out of range. If one iterates through a loop and removes elements from it at the same time, the end of the iterator has to be re-evaluated in each iteration.
* Incorporated review comments.
* Incorporated review comments.
Co-authored-by: kakje <[email protected]>
Intersecting the set of in-scope variables across the predecessors of a basic block excludes most variables that are not in-scope for the basic block. However, an exception is when a variable goes out of scope within the basic block. When this happens, the bug noted above manifests.
Fix:
Enabling the AddLifetime flag during CFG construction produces the CFGLifetimeEnds CFGElement for every variable that goes out of scope. When we encounter this CFGElement, we remove the variable that goes out of scope from the ObservedBounds map if it is a checked pointer, and also delete all available expressions that use this out-of-scope variable.
Problem
The following code should compile
But instead, the 0.8 (release) version of the compiler generates the following error:
Note that the variable
dest
is already out of scope.This should not be an error.
The text was updated successfully, but these errors were encountered: