public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [vta/trunk] don't violate strict aliasing rules in type_hash_add
@ 2007-11-12 20:08 Alexandre Oliva
  2007-11-26  9:27 ` Alexandre Oliva
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Oliva @ 2007-11-12 20:08 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

I noticed we cast a (void**) to (struct type_hash **) and then assign
to the dereferenced pointer.  This is wrong.  What we want is to cast
the (struct type_hash *) object to (void*) and then assign to the
dereferenced (void**), which mirrors the way we read from the hash
table: dereferencing the void** and then casting the void* to (struct
type_hash *).

Ok for the trunk?  Installing in vta.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gcc-tree-type-hash-alias-safety.patch --]
[-- Type: text/x-patch, Size: 629 bytes --]

for  gcc/ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree.c (type_hash_add): Don't violate strict aliasing rules.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c.orig	2007-11-11 20:33:13.000000000 -0200
+++ gcc/tree.c	2007-11-11 20:32:52.000000000 -0200
@@ -4685,7 +4685,7 @@ type_hash_add (hashval_t hashcode, tree 
   h->hash = hashcode;
   h->type = type;
   loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
-  *(struct type_hash **) loc = h;
+  *loc = (void*)h;
 }
 
 /* Given TYPE, and HASHCODE its hash code, return the canonical

[-- Attachment #3: Type: text/plain, Size: 249 bytes --]


-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-15 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12 20:08 [vta/trunk] don't violate strict aliasing rules in type_hash_add Alexandre Oliva
2007-11-26  9:27 ` Alexandre Oliva
2007-12-05 14:21   ` Diego Novillo
2007-12-15 21:46     ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).