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

Re: [PATCH 3/2] Add some more casts (2/2)


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?


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