Follow-up Comment #2, bug #50987 (project avr-libc):

I think it is generally not a good idea to remove volatile from registers
because writing/reading registers generally still has a side effect in
addition to just changing the value.

For example, with volatile register accesses are never reordered (a different
order may have different semantics).

Another example is that some infinite loops like while(1){REG=1;} would become
undefined behavior (at least in C++) without REG being volatile. See:
http://en.cppreference.com/w/cpp/language/memory_model (Progress guarantee).

In summary I think the only case where removing volatile from a register is
where it has no specific hardware semantics at all - reading or writing has no
side effect and the value itself does not influence anything.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?50987>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to