]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Forestall optimization-out of a buffer.
authorStan Shebs <stanshebs@google.com>
Wed, 9 May 2018 18:26:35 +0000 (11:26 -0700)
committerStan Shebs <stanshebs@google.com>
Wed, 9 May 2018 18:26:35 +0000 (11:26 -0700)
string/tst-xbzero-opt.c

index cf7041f37a1357846b4657224893891bbc34b8b3..e9c411b2ef5d1c90b461125eb031f27ad2e0a072 100644 (file)
@@ -110,11 +110,17 @@ prepare_test_buffer (unsigned char *buf)
     abort ();
 }
 
+/* Use a volatile global to ensure that aggressive compilers don't
+   decide that the test buffer is unused and evaporate it.  */
+
+volatile unsigned char *vol_glob;
+
 static void
 setup_no_clear (void)
 {
   unsigned char buf[TEST_BUFFER_SIZE];
   prepare_test_buffer (buf);
+  vol_glob = buf;
 }
 
 static void
@@ -123,6 +129,7 @@ setup_ordinary_clear (void)
   unsigned char buf[TEST_BUFFER_SIZE];
   prepare_test_buffer (buf);
   memset (buf, 0, TEST_BUFFER_SIZE);
+  vol_glob = buf;
 }
 
 static void