GCC warnings for unused global variables
Gabriel Dos Reis
gdr@integrable-solutions.net
Fri May 2 20:27:00 GMT 2003
<tm_gccmail@mail.kloo.net> writes:
| On 2 May 2003, Gabriel Dos Reis wrote:
|
| > Fergus Henderson <fjh@cs.mu.OZ.AU> writes:
| >
| > | On 02-May-2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| > | > prj@po.cwru.edu (Paul Jarc) writes:
| > | >
| > | > | Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| > | > | > Fergus Henderson <fjh@cs.mu.OZ.AU> writes:
| > | > | >| I don't think the committee ever intended to allow implementations
| > | > | >| to optimize away volatile variables,
| > | > | >
| > | > | > Why not? The C standard clearly says:
| > | > | >
| > | > | > [#3] In the abstract machine, all expressions are evaluated
| > | > | > as specified by the semantics. An actual implementation
| > | > | > need not evaluate part of an expression if it can deduce
| > | > | > that its value is not used and that no needed side effects
| > | > ^^^^^^^^^
| > | > | > are produced (including any caused by calling a function or
| > | > | > accessing a volatile object).
| > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| >
| > | > |
| > | > | Accessing a volatile object includes writing, and writing includes
| > | > | initializing. So the initialization cannot be optimized out.
| > | >
| > | > Why? the last part of the paragraph quoted above does specifically
| > | > permit that optimization where applicable.
| > |
| > | In the case of accesses to volatile objects, it is never applicable.
| >
| > Even when the standard writes it? Hugh.
|
| Seemingly meaningless read/writes from/to volatile variables usually have
The discussion was not about "seemingly meaningless read/writes".
Please to not confuse the matter further.
-- Gaby
More information about the Gcc
mailing list