AVR C Runtime Library - Bugs: bug #50987, Not all registers need to be...
You are not allowed to post comments on this tracker with your current authentication level.
bug #50987: Not all registers need to be declared volatile
Submitter: | Eric Tang <e_l_tang> | ||
Submitted: | Tue 09 May 2017 08:20:25 PM UTC | ||
Category: | None | Severity: | 3 - Normal |
Priority: | 5 - Normal | Item Group: | None |
Status: | None | Percent Complete: | 0% |
Assigned to: | None | Open/Closed: | Open |
Release: | 2.0.0 | Fixed Release: | None |
Sat 23 Dec 2017 10:33:22 AM UTC, comment #3: |
Anonymous |
Tue 09 May 2017 08:51:41 PM UTC, comment #2: 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.
|
Ambroz Bizjak <abizjak> |
Tue 09 May 2017 08:33:26 PM UTC, comment #1: Would you be a /bit/ more specific? |
Georg-Johann Lay <gjlayde> |
Tue 09 May 2017 08:20:25 PM UTC, original submission:
Many registers are no different from a global 8-bit variables in that they will always contain the values which were last written to them. The compiler will be able to better optimize code which accesses them if they are not declared volatile. |
Eric Tang <e_l_tang> |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
As Ambroz explained, removing volatile is only safe if there are no (side) effects. This case IMHO never happens (each register is there for a specific purpose/effect). The registers with the least hardware side effects probably are the GPIOn registers, which are effectively like global variables. When I use them, it's usually in ISRs, thus, they must be declared volatile.
Voting to close the bug as wontfix.