"raof01" <ra****@gmail.comwrote in message
news:7c*************************@news.cn99.com...
Hello Joachim,
>Because for some stupid reason in C const doesn't mean 'constant' but
'read only'
Yes, absolutely. Furthermore, "const" means read only JUST for you. On the
other hand, "volatile" doesn't mean you can modify it but you HAVE TO
reload it from memory every time you use it. "volatile" is more like an
indicator for compiler to protect from optimizing.
Its not clear at what level a compiler will stop optimizing; its all
implementation defined. It seems like link-time optimizations can mess
around with volatiles if they can obtain certain levels of information... I
think smart-a$@ compilers think they can reorder something, and ultimately
end up generating phantom behavior under the random nature of various
race-conditions. This is especially relevant when the 'volatile' keyword is
used in conjunction with multi-threaded algorithms...