This patch fixes bootstrap comparison when doing bootstrap with -fsanitize=undefined enabled. We need to hash the UID of the type and also I had to switch two statements; we need to get TYPE_MAIN_VARIANT of the type first... Hence, no more bootstrap comparison failures. Woohoo!
Tested x86_64-linux, applying to the ubsan branch. 2013-08-23 Marek Polacek <pola...@redhat.com> * ubsan.c (ubsan_typedesc_hasher::hash): Hash the TYPE_UID of the type. (ubsan_type_descriptor): Get TYPE_MAIN_VARIANT before initializing the type descriptor. --- gcc/ubsan.c.mp 2013-08-23 14:28:15.780955545 +0200 +++ gcc/ubsan.c 2013-08-23 14:28:47.467059363 +0200 @@ -60,7 +60,7 @@ struct ubsan_typedesc_hasher inline hashval_t ubsan_typedesc_hasher::hash (const ubsan_typedesc *data) { - return iterative_hash_object (data->type, 0); + return iterative_hash_object (TYPE_UID (data->type), 0); } /* Compare two data types. */ @@ -298,11 +298,11 @@ ubsan_type_descriptor (tree type) { hash_table <ubsan_typedesc_hasher> ht = get_typedesc_hash_table (); ubsan_typedesc d; - ubsan_typedesc_init (&d, type, NULL); /* See through any typedefs. */ type = TYPE_MAIN_VARIANT (type); + ubsan_typedesc_init (&d, type, NULL); ubsan_typedesc **slot = ht.find_slot (&d, INSERT); if (*slot != NULL) /* We have the VAR_DECL in the table. Return it. */ Marek