This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] gcore.c (array_func): Add reference to static_array.
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 15 Sep 2015 21:33:58 +0000
- Subject: [PATCH] gcore.c (array_func): Add reference to static_array.
- Authentication-results: sourceware.org; auth=none
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 ();
}