This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix math wrt volatile-bitfields vs C++ model
- From: DJ Delorie <dj at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Jun 2014 17:35:34 -0400
- Subject: fix math wrt volatile-bitfields vs C++ model
- Authentication-results: sourceware.org; auth=none
If the combined bitfields are exactly the size of the mode, the logic
for detecting range overflow is flawed - it calculates an ending
"position" that's the position of the first bit in the next field.
In the case of "short" for example, you get "16 > 15" without this
patch (comparing size to position), and "15 > 15" with (comparing
position to position).
Ok to apply?
* expmed.c (strict_volatile_bitfield_p): Fix off-by-one error.
Index: expmed.c
===================================================================
--- expmed.c (revision 211479)
+++ expmed.c (working copy)
@@ -472,13 +472,13 @@ strict_volatile_bitfield_p (rtx op0, uns
&& bitnum % GET_MODE_ALIGNMENT (fieldmode) + bitsize > modesize))
return false;
/* Check for cases where the C++ memory model applies. */
if (bitregion_end != 0
&& (bitnum - bitnum % modesize < bitregion_start
- || bitnum - bitnum % modesize + modesize > bitregion_end))
+ || bitnum - bitnum % modesize + modesize - 1 > bitregion_end))
return false;
return true;
}
/* Return true if OP is a memory and if a bitfield of size BITSIZE at