Hacker News new | ask | show | jobs
by peterfirefly 15 days ago
flohofwoe (above) and aw1621107 (next to this post) both figured out that the magic ingredient isn't whether we code an if or add the boolean value of a comparison to the array size. The magic ingredient is whether the store is conditional or not.

Having the compiler convert a conditional store to an unconditional store can have bad consequences if you have interrupts or task switches or SMP going on, so it's not a good idea to do it -- unless you can guarantee that the thread of execution the compiler can see is indeed the only one. Yeah, yeah, volatile and barriers etc... still, not a good idea.