This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Assignment to volatile objects
- From: ZoltÃn KÃcsi <zoltan at bendor dot com dot au>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 31 Jan 2012 09:02:57 +1100
- Subject: Assignment to volatile objects
Now that the new C standard is out, is there any chance that gcc's behaviour
regarding to volatile lhs in an assignment changes?
This is what it does today:
volatile int a, b;
a = b = 0;
translates to
b = 0;
a = b;
because the standard (up to and including C99) stated that the value of the
assignment operator is the value of the lhs after the assignment.
The C11 standard says the same but then it explicitely states that the
compiler does not have to read back the value of the lhs, not even when the
lhs is volatile.
So it is actually legal now not to read back the lhs. Is there a chance for
the compiler to get a switch which would tell it explicitely not to read the
value back?
Zoltan