gcore.c (array_func): Add reference to static_array.

Message ID 001a1136b7ac8deb34051fcff0ec@google.com
State New, archived
Headers

Commit Message

Doug Evans Sept. 15, 2015, 9:33 p.m. UTC
  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.
  

Comments

Doug Evans Sept. 28, 2015, 8:32 p.m. UTC | #1
On Tue, Sep 15, 2015 at 2:33 PM, Doug Evans <dje@google.com> wrote:
> 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.

Committed.
  

Patch

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 ();
  }