fix compile error with clang
Commit Message
On 2018-12-20 4:38 p.m., Dave Murphy wrote:
> Hi Simon,
>
> The error I get is
>
> ../../binutils-gdb/gdb/unittests/observable-selftests.c:73:31: error:
> default initialization of an object of const type 'const
> gdb::observers::token' without a user-provided default constructor
> const gdb::observers::token token1, token2, token3;
> ^
> {}
> clang version is
>
> davem@devkit-builder:~$ /opt/osx/bin/x86_64-apple-darwin15-clang --version
>
> clang version 3.8.1-24 (tags/RELEASE_381/final)
> Target: x86_64-apple-darwin15
> Thread model: posix
>
> (targeting 10.9+ host)
>
> build machine is debian stretch
>
> davem@devkit-builder:~$ uname -a
> Linux devkit-builder 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2
> (2018-10-27) x86_64 GNU/Linux
Thanks for the details, I was able to reproduce using clang 3.8 on Debian stable.
I think it's worth fixing since it doesn't hurt when building other compilers,
and clang 3.8 is still the default clang version on the current Debian stable.
Here's what I pushed:
From 3dcfdc58656caa4a38e1fde73a07a19114347226 Mon Sep 17 00:00:00 2001
From: Dave Murphy <davem@devkitpro.org>
Date: Fri, 21 Dec 2018 11:14:28 -0500
Subject: [PATCH] Fix compile error with clang 3.8
When compiling with clang 3.8 (default clang version on Debian
Stretch, the current stable), we get errors like this:
CXX dtrace-probe.o
../../binutils-gdb/gdb/dtrace-probe.c:103:31: error: default initialization of an object of const type 'const dtrace_static_probe_ops' without a user-provided default constructor
const dtrace_static_probe_ops dtrace_static_probe_ops;
^
Silence them by value-initializing those objects. It's not necessary
with other compilers (later clang versions, gcc), but it shouldn't
hurt either.
---
gdb/ChangeLog | 10 ++++++++++
gdb/dtrace-probe.c | 2 +-
gdb/probe.c | 2 +-
gdb/record-btrace.c | 2 +-
gdb/stap-probe.c | 2 +-
gdb/tui/tui-hooks.c | 2 +-
gdb/unittests/observable-selftests.c | 2 +-
7 files changed, 16 insertions(+), 6 deletions(-)
--
2.20.1
@@ -1,3 +1,13 @@
+2018-12-21 Dave Murphy <davem@devkitpro.org>
+
+ * dtrace-probe.c (dtrace_static_probe_ops): Explicit zero
+ initialise.
+ * probe.c (any_static_probe_ops): Ditto.
+ * record-btrace.c (record_btrace_thread_observer_token): Ditto.
+ * stap-probe.c (stap_static_probe_ops): Ditto.
+ * tui/tui-hooks.c (tui_observers_token): Ditto.
+ * unittests/observable-selftests.c (token1, token2, token3): Ditto.
+
2018-12-19 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb/dummy-frame.c (default_dummy_id): Defined new function.
@@ -100,7 +100,7 @@ public:
/* DTrace static_probe_ops. */
-const dtrace_static_probe_ops dtrace_static_probe_ops;
+const dtrace_static_probe_ops dtrace_static_probe_ops {};
/* The following structure represents a dtrace probe. */
@@ -60,7 +60,7 @@ public:
/* Static operations associated with a generic probe. */
-const any_static_probe_ops any_static_probe_ops;
+const any_static_probe_ops any_static_probe_ops {};
/* A helper for parse_probes that decodes a probe specification in
SEARCH_PSPACE. It appends matching SALs to RESULT. */
@@ -143,7 +143,7 @@ static record_btrace_target record_btrace_ops;
/* Token associated with a new-thread observer enabling branch tracing
for the new thread. */
-static const gdb::observers::token record_btrace_thread_observer_token;
+static const gdb::observers::token record_btrace_thread_observer_token {};
/* Memory access types used in set/show record btrace replay-memory-access. */
static const char replay_memory_access_read_only[] = "read-only";
@@ -119,7 +119,7 @@ public:
/* SystemTap static_probe_ops. */
-const stap_static_probe_ops stap_static_probe_ops;
+const stap_static_probe_ops stap_static_probe_ops {};
class stap_probe : public probe
{
@@ -205,7 +205,7 @@ tui_normal_stop (struct bpstats *bs, int print_frame)
/* Token associated with observers registered while TUI hooks are
installed. */
-static const gdb::observers::token tui_observers_token;
+static const gdb::observers::token tui_observers_token {};
/* Attach or detach a single observer, according to ATTACH. */
@@ -70,7 +70,7 @@ run_tests ()
attached. */
notify_check_counters (0, 0, 0);
- const gdb::observers::token token1, token2, token3;
+ const gdb::observers::token token1 {}, token2 {} , token3 {};
/* Now, attach one observer, and send a notification. */
test_notification.attach (&test_second_notification_function, token2);