From patchwork Wed Feb 4 10:51:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 4907 Received: (qmail 22214 invoked by alias); 4 Feb 2015 10:51:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22201 invoked by uid 89); 4 Feb 2015 10:51:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Feb 2015 10:51:23 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14ApKXO015222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Feb 2015 05:51:20 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t14ApIZK032515; Wed, 4 Feb 2015 05:51:19 -0500 Message-ID: <54D1F9A6.5050309@redhat.com> Date: Wed, 04 Feb 2015 11:51:18 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Patrick Palka CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH 3/3] Simplify event-loop core, remove two-step event processing References: <1422292759-22307-1-git-send-email-palves@redhat.com> <1422292759-22307-4-git-send-email-palves@redhat.com> In-Reply-To: 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 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 + + Fix build breakage. + * event-loop.c (gdb_do_one_event): Add default switch case. + 2015-02-03 Jan Kratochvil 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++;