diff --git a/regex_macros/src/lib.rs b/regex_macros/src/lib.rs
index 620f7b31b9..f6ff922f4e 100644
--- a/regex_macros/src/lib.rs
+++ b/regex_macros/src/lib.rs
@@ -309,7 +309,7 @@ fn exec<'t>(
 
         #[inline]
         fn contains(&self, pc: usize) -> bool {
-            let s = self.sparse[pc];
+            let s = unsafe { ::std::ptr::read_volatile(&self.sparse[pc]) };
             s < self.size && self.dense[s].pc == pc
         }