volatile
Wayne A. Christopher
faustus at ic.Berkeley.EDU
Thu Jun 2 13:37:27 AEST 1988
In article <11783 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
] This last point---that C without `volatile' has been used for systems
] work---seems to have been ignored by those who claim that volatile is
] necessary. (Note that I claim only that it is unnecessary, not that it
] is bad.)
It's unnecessary only if you don't want to optimize the code. The reason
we've gotten by without it is that we haven't had good compilers.
] Let us try an experiment:
]
] f() {
] register int i, *ip;
] i = *ip;
] i = *ip;
] }
]
] produces
]
] movl (r10),r11 # i = *ip
] movl (r10),r11 # i = *ip
]
] That sure looks like the code I would expect from
]
] volatile int *ip;
Only because you're using a bad compiler. I'll bet gcc would give you the
results you expect. I don't think it makes any sense to declare an
automatic variable volatile anyway.
Wayne
More information about the Comp.lang.c
mailing list