Hi, I'm trying to understand what goes on in "lib\system\atomics.nim". This is in part because I'm missing atomicLoadN/atomicStoreN on Windows, and I'm trying to work out how to implement that myself. I've just stumbled upon this declaration (atomics.nim, line #220): interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte {.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
At first, I though using __InterlockedCompareExchange64_ was a bug, but then I found out that there is no __InterlockedCompareExchange8_. So, I guess _exchange_ and _comparand_ get cast to __int64_, and the return value just gets cast to _byte_. So far so good. But __InterlockedCompareExchange64_ assumes _p_ points to a __int64_ value, and so will overwrite the _8 bytes_ at that location. How can that not go horribly wrong?