* [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
* Re: [vta/trunk] don't violate strict aliasing rules in type_hash_add
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
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Oliva @ 2007-11-26 9:27 UTC (permalink / raw)
To: gcc-patches
On Nov 12, 2007, Alexandre Oliva <aoliva@redhat.com> wrote:
> Ok for the trunk? Installing in vta.
> * tree.c (type_hash_add): Don't violate strict aliasing rules.
> Index: gcc/tree.c
> - *(struct type_hash **) loc = h;
> + *loc = (void*)h;
I'm going ahead and checking this in as obviously correct.
--
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
* Re: [vta/trunk] don't violate strict aliasing rules in type_hash_add
2007-11-26 9:27 ` Alexandre Oliva
@ 2007-12-05 14:21 ` Diego Novillo
2007-12-15 21:46 ` Alexandre Oliva
0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2007-12-05 14:21 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-patches
On 11/26/07 1:37 AM, Alexandre Oliva wrote:
> On Nov 12, 2007, Alexandre Oliva <aoliva@redhat.com> wrote:
>
>> Ok for the trunk? Installing in vta.
>
>> * tree.c (type_hash_add): Don't violate strict aliasing rules.
>
>> Index: gcc/tree.c
>> - *(struct type_hash **) loc = h;
>> + *loc = (void*)h;
Space after 'void'.
Diego.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [vta/trunk] don't violate strict aliasing rules in type_hash_add
2007-12-05 14:21 ` Diego Novillo
@ 2007-12-15 21:46 ` Alexandre Oliva
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2007-12-15 21:46 UTC (permalink / raw)
To: Diego Novillo; +Cc: gcc-patches
On Dec 5, 2007, Diego Novillo <dnovillo@google.com> wrote:
> On 11/26/07 1:37 AM, Alexandre Oliva wrote:
>> On Nov 12, 2007, Alexandre Oliva <aoliva@redhat.com> wrote:
>>
>>> Ok for the trunk? Installing in vta.
>>
>>> * tree.c (type_hash_add): Don't violate strict aliasing rules.
>>
>>> Index: gcc/tree.c
>>> - *(struct type_hash **) loc = h;
>>> + *loc = (void*)h;
> Space after 'void'.
Thanks, I'm checking this in. Sorry about the delay.
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* tree.c (type_hash_add): Fix whitespace.
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 130958)
+++ gcc/tree.c (working copy)
@@ -4677,7 +4677,7 @@
h->hash = hashcode;
h->type = type;
loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
- *loc = (void*)h;
+ *loc = (void *)h;
}
/* Given TYPE, and HASHCODE its hash code, return the canonical
--
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).