From a6a9b5594daf3e125b2cb0edce70567b5d56dcb6 Mon Sep 17 00:00:00 2001
From: Arne Goedeke <el@laramies.com>
Date: Wed, 22 Oct 2014 19:01:18 +0200
Subject: [PATCH] Fix -Wglobbered warnings.

One of them was actually legitimate.
---
 src/builtin_functions.c | 6 +++++-
 src/program.c           | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index 24d1751a93..3cdc997c0c 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -4516,7 +4516,11 @@ node *optimize_replace(node *n)
      */
     node **arg1 = my_get_arg(&_CDR(n), 1);
     node **arg2 = my_get_arg(&_CDR(n), 2);
-    struct program *replace_compiler = NULL;
+
+    /* This variable is modified in between setjmp and longjmp,
+     * so it needs to be volatile to prevent it from being globbered.
+     */
+    struct program * volatile replace_compiler = NULL;
 
     if (arg1 && ((pike_types_le((*arg1)->type, array_type_string) &&
 		  arg2 &&
diff --git a/src/program.c b/src/program.c
index c73878f86e..7c3e36ed46 100644
--- a/src/program.c
+++ b/src/program.c
@@ -1781,8 +1781,11 @@ int low_find_shared_string_identifier(struct pike_string *name,
 
 static struct node_s *index_modules(struct pike_string *ident,
 				    struct mapping **module_index_cache,
-				    int num_used_modules,
+				    const int num_used_modules,
 				    struct svalue *modules)
+  /* num_used_modules is declared const here to convince the compiler that it is not
+   * modified in between setjmp() and longjmp(). This prevents -Wglobbered warnings.
+   */
 {
   if(*module_index_cache)
   {
-- 
GitLab