volatile [was: GCC warnings for unused global variables]
Richard Henderson
rth@redhat.com
Wed May 7 23:15:00 GMT 2003
On Wed, May 07, 2003 at 03:58:24PM -0700, Mike Stump wrote:
> On Tuesday, May 6, 2003, at 09:03 PM, Alexandre Oliva wrote:
> >But then, so is a single instruction that loads, operates then stores,
> >right? The thing is that GCC doesn't ever give such instruction a
> >chance if the variable is volatile.
>
> But, obviously, it should be made to.
No, that's not obvious at all.
It means that, the behaviour of the program is going to depend on
(1) Whether the source was written as "i++" or "i += 1" or "i = i + 1".
I think this would be astonishing to most C programmers.
(2) Whether the architecture supports load/op/store instructions at all.
This reduces portability of driver code across architectures.
Given the difficulty of validating driver code in the first
place, this is surely a big lose.
(3) Whether a particular revision of an architecture issues its
load/op/store bus cycles in the same manner. IIRC, 68000 vs
68020 is an example of this sort of change.
(4) GCC has never in its history issued load/op/store operations
for volatiles, and changing it now may well break previously
written drivers. This would, in effect, be an ABI change.
r~
More information about the Gcc
mailing list