Message ID | 1446062352-27859-1-git-send-email-palves@redhat.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 11706 invoked by alias); 28 Oct 2015 19:59:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11689 invoked by uid 89); 28 Oct 2015 19:59:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS 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, 28 Oct 2015 19:59:15 +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 (Postfix) with ESMTPS id 5DBF0C0AEE20; Wed, 28 Oct 2015 19:59:14 +0000 (UTC) Received: from brno.lan (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 t9SJxCmv020429; Wed, 28 Oct 2015 15:59:13 -0400 From: Pedro Alves <palves@redhat.com> To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@polymtl.ca> Subject: [PATCH] Add cast to VEC_iterate Date: Wed, 28 Oct 2015 19:59:12 +0000 Message-Id: <1446062352-27859-1-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit |
Commit Message
Pedro Alves
Oct. 28, 2015, 7:59 p.m. UTC
Fixes this in C++: ../../src/gdb/break-catch-sig.c: In function ‘int VEC_gdb_signal_type_iterate(const VEC_gdb_signal_type*, unsigned int, gdb_signal_type*)’: ../../src/gdb/common/vec.h:576:12: error: invalid conversion from ‘int’ to ‘gdb_signal_type {aka gdb_signal}’ [-fpermissive] *ptr = 0; \ ^ ../../src/gdb/common/vec.h:417:1: note: in expansion of macro ‘DEF_VEC_FUNC_P’ DEF_VEC_FUNC_P(T) \ ^ ../../src/gdb/break-catch-sig.c:37:1: note: in expansion of macro ‘DEF_VEC_I’ DEF_VEC_I (gdb_signal_type); ^ I actually carried a different fix in the C++ branch that removed this assignment and then adjusted all callers that depended on it. The thinking was that this is for the case where we're returning false, indicating end of iteration. But that results in a much larger and tricker patch; looking back it seems quite pointless. I looked at the history of GCC's C++ conversion and saw that they added this same cast to their version of vec.h, FWIW. (GCC's vec.h is completely different nowadays, having been converted to templates meanwhile.) gdb/ChangeLog: 2015-10-28 Pedro Alves <palves@redhat.com> * common/vec.h (DEF_VEC_FUNC_P) [iterate]: Cast 0 to type T. --- gdb/common/vec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 28 October 2015 at 15:59, Pedro Alves <palves@redhat.com> wrote: > Fixes this in C++: > > ../../src/gdb/break-catch-sig.c: In function ‘int VEC_gdb_signal_type_iterate(const VEC_gdb_signal_type*, unsigned int, gdb_signal_type*)’: > ../../src/gdb/common/vec.h:576:12: error: invalid conversion from ‘int’ to ‘gdb_signal_type {aka gdb_signal}’ [-fpermissive] > *ptr = 0; \ > ^ > ../../src/gdb/common/vec.h:417:1: note: in expansion of macro ‘DEF_VEC_FUNC_P’ > DEF_VEC_FUNC_P(T) \ > ^ > ../../src/gdb/break-catch-sig.c:37:1: note: in expansion of macro ‘DEF_VEC_I’ > DEF_VEC_I (gdb_signal_type); > ^ > > I actually carried a different fix in the C++ branch that removed this > assignment and then adjusted all callers that depended on it. The > thinking was that this is for the case where we're returning false, > indicating end of iteration. But that results in a much larger and > tricker patch; looking back it seems quite pointless. I looked at the > history of GCC's C++ conversion and saw that they added this same cast > to their version of vec.h, FWIW. (GCC's vec.h is completely different > nowadays, having been converted to templates meanwhile.) > > gdb/ChangeLog: > 2015-10-28 Pedro Alves <palves@redhat.com> > > * common/vec.h (DEF_VEC_FUNC_P) [iterate]: Cast 0 to type T. > --- > gdb/common/vec.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/common/vec.h b/gdb/common/vec.h > index 2564485..6189283 100644 > --- a/gdb/common/vec.h > +++ b/gdb/common/vec.h > @@ -573,7 +573,7 @@ static inline int VEC_OP (T,iterate) \ > } \ > else \ > { \ > - *ptr = 0; \ > + *ptr = (T) 0; \ > return 0; \ > } \ > } \ > -- > 1.9.3 > LGTM.
On 10/28/2015 08:33 PM, Simon Marchi wrote: > LGTM. > Thanks. I pushed it in. Thanks, Pedro Alves
diff --git a/gdb/common/vec.h b/gdb/common/vec.h index 2564485..6189283 100644 --- a/gdb/common/vec.h +++ b/gdb/common/vec.h @@ -573,7 +573,7 @@ static inline int VEC_OP (T,iterate) \ } \ else \ { \ - *ptr = 0; \ + *ptr = (T) 0; \ return 0; \ } \ } \