[C++] Fix -Winvalid-offsetof warnings with g++ 4.4
authorPedro Alves <palves@redhat.com>
Wed, 16 Dec 2015 19:25:32 +0000 (19:25 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 16 Dec 2015 19:25:32 +0000 (19:25 +0000)
commita4e22a5df64a46bc99f737a982c0b9d1e8a45e2b
tree7c0b9ab159fba2c2565ac47f8dcd8c4ea1dfaeb0
parent72d98d16ed09584660d0cbb759d90f8dfeef2343
[C++] Fix -Winvalid-offsetof warnings with g++ 4.4

Ref: https://sourceware.org/ml/gdb/2015-12/msg00014.html

Fixes the build in C++ mode with g++ 4.4:

 gdb/btrace.h: In function ‘size_t VEC_btrace_insn_s_embedded_size(int)’:
 gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’  of NULL object
 gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly)
 gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_alloc(int)’:
 gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’  of NULL object
 gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly)
 gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_copy(VEC_btrace_insn_s*)’:
 gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’  of NULL object
 gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly)
 gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_merge(VEC_btrace_insn_s*, VEC_btrace_insn_s*)’:
 gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’  of NULL object
 gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly)
 gdb/btrace.h: In function ‘int VEC_btrace_insn_s_reserve(VEC_btrace_insn_s**, int, const char*, unsigned int)’:
 gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’  of NULL object
 gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly)

gdb/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

* common/vec.h (vec_offset): New macro.
(DEF_VEC_ALLOC_FUNC_I, DEF_VEC_ALLOC_FUNC_O): Use it instead of
offsetof.
gdb/ChangeLog
gdb/common/vec.h
This page took 0.026263 seconds and 4 git commands to generate.