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]

Re: [PATCH 3/3] Simplify event-loop core, remove two-step event processing


On 02/03/2015 11:48 PM, Patrick Palka wrote:
> This patch causes a build failure when compiling GDB with GCC 4.9:
> 
> /home/patrick/code/binutils-gdb/gdb/event-loop.c: In function
> âgdb_do_one_eventâ:
> /home/patrick/code/binutils-gdb/gdb/event-loop.c:296:10: error: âresâ
> may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>        if (res > 0)
>           ^
> 

Bah, -O0 vs -O2.  I've pushed the fix below.

-------
Subject: [PATCH] Fix build breakage due to event loop simplification

commit 70b66289 (Simplify event-loop core, remove two-step event
processing) causes a build failure when compiling GDB with gcc/-O2:

 gdb/event-loop.c: In function âgdb_do_one_eventâ:
 gdb/event-loop.c:296:10: error: âresâ may be used uninitialized in this function
 [-Werror=maybe-uninitialized]
	if (res > 0)
	   ^

GCC isn't realizing that event_source_head can never be > 2 and that
therefore 'res' is always initialized in all possible paths.  Adding a
default case that internal_error's makes GCC realize that.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

	Fix build breakage.
	* event-loop.c (gdb_do_one_event): Add default switch case.
---
 gdb/ChangeLog    | 5 +++++
 gdb/event-loop.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2266c11..1116853 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-04  Pedro Alves  <palves@redhat.com>
+
+	Fix build breakage.
+	* event-loop.c (gdb_do_one_event): Add default switch case.
+
 2015-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	Filter out inferior gcc option -fpreprocessed.
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index 7425b3a..a2b41a7 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -287,6 +287,10 @@ gdb_do_one_event (void)
 	  /* Are there any asynchronous event handlers ready?  */
 	  res = check_async_event_handlers ();
 	  break;
+	default:
+	  internal_error (__FILE__, __LINE__,
+			  "unexpected event_source_head %d",
+			  event_source_head);
 	}
 
       event_source_head++;
-- 
1.9.3



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