Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Incorrect Variable Name #37

Closed
MarkChenYutian opened this issue Jan 27, 2023 · 0 comments · Fixed by #38
Closed

[Bug Report] Incorrect Variable Name #37

MarkChenYutian opened this issue Jan 27, 2023 · 0 comments · Fixed by #38
Assignees
Labels
bug Something isn't working VM Core Change in VM Core is needed

Comments

@MarkChenYutian
Copy link
Owner

Describe the bug
The C0 -> BC0 compiler will reuse the elements in local variable array when possible. This means that a same element (index) in the local variable array may have different name and type during the runtime.

Specifically, suppose some variable x is declared in a scope and some other new variable y is declared after the scope x is in, the cc0 compiler will reuse the local variable array index for x previously to store value of y.

To Reproduce
Steps to reproduce the behavior:

  1. Compile the code below
  2. Set breakpoint on the line that contains int[] K = array_copy(...)
  3. Run the program
  4. In tabular debugger (and also graphical), the variable should have name J instead of i, which is already out of scope.

Expected behavior
As described above.

Screenshots

Code being executed

int[] array_copy(int[] A, int n)
//@requires n == \length(A);
//@ensures \length(\result) == n;
{
  int[] B = alloc_array(int, n);
  for (int i = 0; i < n; i ++) 
  //@loop_invariant 0 <= i;
  {
    B[i] = A[i];
  }
  return B;
}

int main() {
  int[] I = alloc_array(int, 3);
  for (int i = 0; i<3; i++) I[i] = i + 5;
  int[] J = array_copy(I, 3);
  int[] K = array_copy(J, 3);
  return 0;
}

Additional Context

(N/A)

-This bug is reported by Prof. Iliano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working VM Core Change in VM Core is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant