1. 10

Original title: Customers not getting the widgets they paid for if they click too fast -or- In C#, the += operator is not merely not guaranteed to be atomic, it is guaranteed not to be atomic

  1.  

  2. 2

    A cool bit of foolishness. :)

    A C compiler has considerable flexibility here, and would probably do the opposite, evaluating the function first, then x. Probably how one would expect it to go as well. The c# ordering seems strange, but makes sense given a little thought. They went to considerable effort to define the order of such edge cases to make an overall less surprising language.

    1. 2

      It is more surprising behavior if it is unexpected. How many people can honestly admit to have read the full language spec??

      1. 5

        The less surprising part is perhaps not that it does what you immediately expect, but that it always does the same thing on 32-bit and 64-bit and on x86 and arm, etc. Everywhere the C spec says implementation defined, the C# spec says defined as follows…