This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Incrementing volatiles?
- To: Bill Currie <bcurrie at tssc dot co dot nz>, law at cygnus dot com
- Subject: Re: Incrementing volatiles?
- From: "Matthias Urlichs" <smurf at noris dot de>
- Date: Thu, 16 Jul 1998 02:35:28 +0200
- Cc: Andreas Schwab <schwab at issan dot informatik dot uni-dortmund dot de>, Horst von Brand <vonbrand at inf dot utfsm dot cl>, egcs at cygnus dot com
- References: <21583.900542629@hurl.cygnus.com> <35AD374A.7E72@tssc.co.nz>
Hi,
Bill Currie:
>
> and "return foo++" could be
>
> bar:
> movl foo,%eax
> incl foo
> ret
>
Wrong. The foo++ means "read it, perhaps do something with the value,
increment the value, put it back". Your assembly code reads the value
twice.
> Now, if I'm really off track, can someone please give me some pointers
> to information that will set me right?
>
"volatile" is massively undefined. My off-the-seat-of-my-pants definition
is that volatile variables are _always_ accessed exactly as many times, and
in exactly that order, as described in the C source code.
How to tell the backend (Intel or otherwise) that sometimes(!) it can
combine a read-add_one-write insn sequence into one "incr", even if the
to-be-incremented thing in question is marked as volatile, is an
interesting question. IMHO, however, "two volatiles never match" is a bit
too strong.
--
Matthias Urlichs
noris network GmbH