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

Problem with copy propagation #11

Open
rcastano opened this issue Jul 30, 2018 · 0 comments
Open

Problem with copy propagation #11

rcastano opened this issue Jul 30, 2018 · 0 comments
Assignees
Labels

Comments

@rcastano
Copy link

The following code causes the copy propagation pass to remove instructions that alter the semantics of the program:

using System;
using System.Diagnostics.Contracts;
class IntContainer {
    public int val;
    public IntContainer(int i) {
        val = i;
    }
}
class Test {
  public static void ShouldPass() {
      var ic = new IntContainer(3);
      F(ic);
  }
  
  public static void F(IntContainer x) {
    IntContainer ic;
    ic = x ?? new IntContainer(4);
    // ic = x != null ? x : new IntContainer(4);
    Contract.Assert(ic != null);
    Contract.Assert(x == null ? ic.val == 4 : ic.val == x.val);
  }
}

@edgardozoppi edgardozoppi self-assigned this Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants