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
usingSystem;classProgram{staticintGetInt(){Console.WriteLine("got int");return42;}intintField;staticvoidFieldAccessOrderOfEvaluation(Programc){Console.WriteLine("NRE before GetInt:");try{refinti=refc.intField;i=GetInt();}catch(Exceptionex){Console.WriteLine(ex.Message);}}}
Erroneous output
privatestaticvoidFieldAccessOrderOfEvaluation(Programc){Console.WriteLine("NRE before GetInt:");try{c.intField=GetInt();}catch(Exceptionex){Console.WriteLine(ex.Message);}}
This output is wrong because when called with c == null, the GetInt side-effect will happen before the NullReferenceException is throws, whereas in the original code the exception was thrown before GetInt was called.
…TargetSlot.
The C# translation of StObj will always apply delayed exceptions in these two cases, so putting an instruction with delayed exceptions in that slot would change program semantics.
Input code
Erroneous output
This output is wrong because when called with
c == null
, theGetInt
side-effect will happen before theNullReferenceException
is throws, whereas in the original code the exception was thrown beforeGetInt
was called.Expected output
Same as original input.
Details
The text was updated successfully, but these errors were encountered: