diff mbox

Fix sub-word CAS synthesis on LP64 targets

Message ID 1414125158-198353-1-git-send-email-waterman@cs.berkeley.edu
State New
Headers show

Commit Message

Andrew Waterman Oct. 24, 2014, 4:32 a.m. UTC
A missing cast causes the compare value to be truncated, resulting in
spurious CAS failures.

The problem manifested in a new port I'm working on as a failure in test
gcc.dg/atomic/c11-atomic-exec-2.c, and I've confirmed that this patch
fixes it.  I also verified that x86_64-unknown-linux still bootstraps
(which is admittedly vacuous, since x86-64 doesn't exercise this code).

2014-10-23  Andrew Waterman <waterman@cs.berkeley.edu>

  * cas_n.c (libat_compare_exchange): Add missing cast.
---
 libatomic/cas_n.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libatomic/cas_n.c b/libatomic/cas_n.c
index 801262d..a885afa 100644
--- a/libatomic/cas_n.c
+++ b/libatomic/cas_n.c
@@ -70,7 +70,7 @@  SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
       mask = -1;
     }
 
-  weval = *eptr << shift;
+  weval = (UWORD)*eptr << shift;
   wnewval = (UWORD)newval << shift;
   woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
   do