This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gcore.c (array_func): Add reference to static_array.


Hi.

This test fails with clang because it discards static_array,
it's unreferenced anywhere.

Is there a preferred way to handle this?
The current way is chosen for portability (instead of, say,
an attribute).

2015-09-15  Doug Evans  <dje@google.com>

	* gdb.base/gcore.c (array_func): Add reference to static_array.

diff --git a/gdb/testsuite/gdb.base/gcore.c b/gdb/testsuite/gdb.base/gcore.c
index d6acc1f..b6d8d54 100644
--- a/gdb/testsuite/gdb.base/gcore.c
+++ b/gdb/testsuite/gdb.base/gcore.c
@@ -46,6 +46,8 @@ array_func ()
       un_initialized_array[i] = extern_array[i] + 8;
       local_array[i] = extern_array[i] + 12;
     }
+  /* Reference static_array so that clang doesn't discard it.  */
+  (void) static_array[0];
   terminal_func ();
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]