Avoid gcc warning on sparc solaris 9

Pedro Alves pedro_alves@portugalmail.pt
Wed Oct 24 13:28:00 GMT 2007


Ulrich Weigand wrote:
> Pedro Alves wrote:
>
> > Building HEAD on a native gdb on sparc solaris 9 with gcc 3.4.6 stops due to:
> >
> > ../../src/gdb/sol-thread.c: In function `sol_thread_fetch_registers':
> > ../../src/gdb/sol-thread.c:533: warning: dereferencing type-punned
> > pointer will break strict-aliasing rules
>
> We've seen this on other platforms with gcc 3.4 as well.  I think
> the best fix would be replace the problematic construct
>   supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
> with
>
>  gdb_gregset_t *gregset_p = &gregset;
>
>  supply_gregset (regcache, (const gdb_gregset_t *) gregset_p);
>
> That seemed to fix the problems e.g. in i386-linux-nat.c (fetch_regs).
>

Indeed it does fix it here too.  Much nicer.  Thanks for the pointer.

Testsuite shows the same results as the previous version.

OK now?

-- 
Cheers,
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: solaris.diff
Type: text/x-patch
Size: 1244 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20071024/0863bacf/attachment.bin>


More information about the Gdb-patches mailing list