3 ms·
This is only a problem if you are using threads or shared memory and making up your own misguided locking mechanisms or in embed code on a processor with interr
by jcoffland 9y ago
This is only a problem if you are using threads or shared memory and making up your own misguided locking mechanisms or in embed code on a processor with interrupts but no locks. Normally, if you use the tools correctly you will never have to worry about compiler reordering messing anything up.
The article you linked discusses what happens when you do things you should not, like fail to initialize a variable before using it. Modern compilers, when used correctly will let you know when you do this. With the right compiler options, it won't allow you to make such mistakes.
- btilly 9y agoThe example in the case that I linked was single threaded code having a check for a null pointer unexpectedly removed. So no threads, no shared memory, no locking mechanisms, no interrupts. Just a compiler making valid optimization and removing a necessary guard condition. Try again.