This is the mail archive of the mailing list for the GCC 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]

[vta/trunk] don't violate strict aliasing rules in type_hash_add

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.

for  gcc/ChangeLog.vta
from  Alexandre Oliva  <>

	* 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
Alexandre Oliva
FSF Latin America Board Member
Red Hat Compiler Engineer   aoliva@{,}
Free Software Evangelist  oliva@{,}

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