-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
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);
}
}