This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 3/2] Add some more casts (2/2)
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: Yao Qi <qiyaoltc at gmail dot com>, <gdb-patches at sourceware dot org>
- Date: Mon, 28 Sep 2015 13:14:23 -0400
- Subject: Re: [PATCH 3/2] Add some more casts (2/2)
- Authentication-results: sourceware.org; auth=none
- References: <20150928154518 dot 474FC2210 at oc7340732750 dot ibm dot com>
On 15-09-28 11:45 AM, Ulrich Weigand wrote:
> Simon Marchi wrote:
>
>> @@ -1350,7 +1352,7 @@ ppu2spu_sniffer (const struct frame_unwind *self,
>> info.bfd_arch_info = bfd_lookup_arch (bfd_arch_spu, bfd_mach_spu);
>> info.byte_order = BFD_ENDIAN_BIG;
>> info.osabi = GDB_OSABI_LINUX;
>> - info.tdep_info = (void *) &data.id;
>> + info.tdep_info = (struct gdbarch_tdep_info *) &data.id;
>> data.gdbarch = gdbarch_find_by_info (info);
>> if (!data.gdbarch)
>> return 0;
>
> This causes compilation to fail (with the RHEL5 system compiler):
>
> gdb/ppc-linux-tdep.c: In function 'ppu2spu_sniffer':
> gdb/ppc-linux-tdep.c:1355: warning: type-punning to incomplete type might break strict-aliasing rules
>
> The problem seems to be that "struct gdbarch_tdep_info" actually
> does not exist and is not defined anywhere. The info.tdep_info
> field is used as a generic pointer; different architectures use
> it for diffferent purposes.
>
> Maybe in this case the correct fix would be to leave the (void *)
> casts in place and actually change the type of the field to void * ...
>
> Bye,
> Ulrich
Thanks for pointing this out. I was able to reproduce it using a Centos 5
docker container.
Changing the field and the cast to void* is ok to me. I don't see any real
value in casting to a pointer to a type that doesn't exist. Any other
opinions?