Add cast to VEC_iterate
authorPedro Alves <palves@redhat.com>
Thu, 29 Oct 2015 15:25:08 +0000 (15:25 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 29 Oct 2015 17:39:33 +0000 (17:39 +0000)
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.

gdb/ChangeLog
gdb/common/vec.h

index 94332211751e1174a3f37ccfeb497d8b29c23bd4..c22eb46c457f69ad4cc1535194e8be7462fa0aff 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 25644857abefee039fd3e8ed649e6998aca9b79e..6189283a03b86f0c8512bf2611f31bd773325f7e 100644 (file)
@@ -573,7 +573,7 @@ static inline int VEC_OP (T,iterate)                                          \
     }                                                                    \
   else                                                                   \
     {                                                                    \
-      *ptr = 0;                                                                  \
+      *ptr = (T) 0;                                                      \
       return 0;                                                                  \
     }                                                                    \
 }                                                                        \