This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
GCC warning: "dereferencing type-punned pointer will break strict-aliasing rules" in sol-thread.c
- From: Jiri Hruska <jiri dot hruska at fud dot cz>
- To: gdb-patches at sourceware dot org
- Date: Fri, 12 Oct 2007 12:56:06 +0200
- Subject: GCC warning: "dereferencing type-punned pointer will break strict-aliasing rules" in sol-thread.c
- Reply-to: Jiri Hruska <jiri dot hruska at fud dot cz>
Hi all,
I just tried to compile latest gdb release 6.7 and it ended with the
following warning:
sol-thread.c: In function `sol_thread_fetch_registers':
sol-thread.c:533: warning: dereferencing type-punned pointer will break
strict-aliasing rules
Because of -Werrors, the whole build fails.
Although I don't know if the something can go wrong if the check is
overriden in this case (I haven't studied the passed structure etc.), after
the simple modification below it compiles fine.
--- gdb-6.7/gdb/sol-thread.c.orig 2007-10-12 12:42:29.649297941 +0200
+++ gdb-6.7/gdb/sol-thread.c 2007-10-12 12:36:26.644462488 +0200
@@ -530,7 +530,7 @@
calling the td routines because the td routines call ps_lget*
which affect the values stored in the registers array. */
- supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
+ supply_gregset (regcache, (const gdb_gregset_t *) (const void *) &gregset);
supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset);
#if 0
$ uname -a
SunOS karamalz 5.8 Generic_117350-27 sun4u sparc SUNW,UltraAX-i2
$ gcc -v
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.6/specs
Configured with: /tmp/gcc-3.4.6/configure --with-gnu-ld --with-gnu-as --enable-languages=c,c++
Thread model: posix
gcc version 3.4.6
Regards,
Jiri Hruska
mailto:jiri.hruska@fud.cz