Skip to content

Problem with copy propagation #11

@rcastano

Description

@rcastano

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);
  }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions