This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC warnings for unused global variables
Paul Koning <pkoning@equallogic.com> writes:
| >>>>> "Gabriel" == Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
|
| Gabriel> Paul Koning <pkoning@equallogic.com> writes:
| >> I can't tell if you're trying to say something that goes directly
| >> against the intent of volatile or not, so let's talk about an
| >> example:
|
| Gabriel> I'm trying to say that "volatile" is not a *reliable*
| Gabriel> feature to use to write robust code with reproducible
| Gabriel> behaviour.
|
| I don't understand.
|
| "volatile" exists in order to be able to write device drivers and
| multiprocessor applications that are robust and have reproducible
| behavior. That's how it has always been used; that's why it exists.
|
| Now you seem to be saying that such code is just lucky when it works.
| Why?
I gave the reasons in previous messages. In the past, I also gave the
reasons on comp.std.c.
The key point boils down to the fact that the semantics of "volatile"
is not well-defined. And I think I've already demonstrated that point.
[...]
| On the other hand, if you mean "it doesn't currently but at some point
| in the future gcc will start doing this because it thinks it can make
Yes, that is what I meant.
| that determination" then at that point every OS and SMP application
| will break.
Not every. Only those that relied on (mis)fortune.
And the following quote is from someone known to have spent a certain
amount of his time on writing OSes:
In short, "volatile" is a bad feature. It's not well-defined, and
whatever the compiler does you can't really complain. In my opinion,
any code that depends on volatile is almost certainly buggy as the
standard stands now (the only case I really personally approve of is
a "clock tick counter" kind of use)
Linus
-- Gaby