ea12b6
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
ea12b6
index 6dfbb4642..9f30b2749 100644
ea12b6
--- a/gcc/cfgexpand.c
ea12b6
+++ b/gcc/cfgexpand.c
ea12b6
@@ -316,6 +316,15 @@ stack_var_conflict_p (size_t x, size_t y)
ea12b6
   struct stack_var *b = &stack_vars[y];
ea12b6
   if (x == y)
ea12b6
     return false;
ea12b6
+  /* GCC 4.8 does not calculate the control flow for setjmp correctly
ea12b6
+     (BZ 56982).  This might lead to merging stack variable slots
ea12b6
+     which in fact are live at the same time.  The following check
ea12b6
+     considers all variables being live across setjmp invocations
ea12b6
+     (these must be marked volatile) to conflict with all other stack
ea12b6
+     variables.  */
ea12b6
+  if (cfun->calls_setjmp
ea12b6
+      && (TREE_THIS_VOLATILE (a->decl) || TREE_THIS_VOLATILE (b->decl)))
ea12b6
+    return true;
ea12b6
   /* Partitions containing an SSA name result from gimple registers
ea12b6
      with things like unsupported modes.  They are top-level and
ea12b6
      hence conflict with everything else.  */