I am currently testing the following patch for PR48098 which exposes the fact that TREE_TYPE (vector-type) does not return T when vector-type is built using make_vector_type (T). This is because we move all qualifiers from T to the vector-type and keep an unqualified element type. This finally confuses us with the requirement to preserve conversions to restrict qualified pointers.
I need to think about this more. For now make the check symmetric (it's a bug that it wasn't) and compare unqualified types. Any issues this hides are missed optimizations with respect to restrict handling. It also eventually just postpones verification ICEs to later phases. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2011-03-14 Richard Guenther <rguent...@suse.de> PR middle-end/48098 * tree.c (build_vector_from_val): Adjust assert to requirements and reality. * gcc.dg/torture/pr48098.c: New testcase. Index: gcc/tree.c =================================================================== *** gcc/tree.c (revision 170933) --- gcc/tree.c (working copy) *************** build_vector_from_val (tree vectype, tre *** 1376,1383 **** if (sc == error_mark_node) return sc; ! gcc_assert (useless_type_conversion_p (TREE_TYPE (sc), ! TREE_TYPE (vectype))); v = VEC_alloc (constructor_elt, gc, nunits); for (i = 0; i < nunits; ++i) --- 1376,1389 ---- if (sc == error_mark_node) return sc; ! /* Verify that the vector type is suitable for SC. Note that there ! is some inconsistency in the type-system with respect to restrict ! qualifications of pointers. Vector types always have a main-variant ! element type and the qualification is applied to the vector-type. ! So TREE_TYPE (vector-type) does not return a properly qualified ! vector element-type. */ ! gcc_checking_assert (types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (sc)), ! TREE_TYPE (vectype))); v = VEC_alloc (constructor_elt, gc, nunits); for (i = 0; i < nunits; ++i) Index: gcc/testsuite/gcc.dg/torture/pr48098.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr48098.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr48098.c (revision 0) *************** *** 0 **** --- 1,12 ---- + /* { dg-do compile } */ + + void + foo (int n) + { + static char *__restrict *p; + int i; + p = __builtin_malloc (n); + for (i = 0; i < n; i++) + p[i] = 0; + } +