|Subject:||Re: [avr-gcc-list] avr-g++ local variable constructor / block body/ destructor execution order|
|Date:||Thu, 06 Sep 2007 07:09:09 -0400|
David Brown wrote:
I believe [the compiler] can [change order of ... volatile objects access]. Obviously it is only legal if such moves do not affect the volatile accesses themselves. Perhaps someone here who has a better knowledge of the standards ...
I wouldn't claim better knowledge, but this is a sore spot for me so I'm going to chime in anyway.
I think that the compiler is not permitted to change the order in which volatile objects are accessed. This would undermine the intent of volatile, which is to give the user exactly what he asks for. My impression is that the C language is defined in terms of the behavior of an abstract machine, which lacks all optimization and operates in a very simplistic but easy-to-describe manner. An actual compiler is allowed to deviate from this, in order to perform optimization, on condition that the resulting behavior is indistinguishable from the abstract machine at certain places called sequence points. In addition, when manipulating volatile objects, it is not allowed to deviate at all from the abstract machine.
|[Prev in Thread]||Current Thread||[Next in Thread]|