This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Add cast to VEC_iterate


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7535d5edeaa5cfa5ba369e8d3ffb47972483394a

commit 7535d5edeaa5cfa5ba369e8d3ffb47972483394a
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Oct 29 15:25:08 2015 +0000

    Add cast to VEC_iterate
    
    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-29  Pedro Alves  <palves@redhat.com>
    
    	* common/vec.h (DEF_VEC_FUNC_P) [iterate]: Cast 0 to type T.

Diff:
---
 gdb/ChangeLog    | 4 ++++
 gdb/common/vec.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9433221..c22eb46 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2015-10-29  Pedro Alves  <palves@redhat.com>
 
+	* common/vec.h (DEF_VEC_FUNC_P) [iterate]: Cast 0 to type T.
+
+2015-10-29  Pedro Alves  <palves@redhat.com>
+
 	* guile/scm-frame.c (gdbscm_unwind_stop_reason_string): Add cast.
 
 2015-10-29  Eli Zaretskii  <eliz@gnu.org>
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;								  \
     }									  \
 }									  \


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