https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Not really sure if this is about dependent type or not, because the following fails too: template <typename V> struct D { V v; int f1 () { return this->v[N-1]; } int f2 () { return v[N-1]; } }; int main () { typedef int V1 __attribute__((vector_size (4 * sizeof (int)))); typedef int V2 __attribute__((vector_size (8 * sizeof (int)))); D<V1> a = { { 0, 1, 2, 3 } }; D<V2> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } }; if (a.f1 () != 3 || a.f2 () != 3 || b.f1 () != 7 || b.f2 () != 7) __builtin_abort (); } I've tried: --- pt.c.jj4 2016-08-06 12:11:45.000000000 +0200 +++ pt.c (TREE_C2016-08-08 20:03:33.217898449 +0200 @@ -22687,6 +22687,11 @@ dependent_type_p_r (tree type)D (expression, 0)); if (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (scope))))) return true;_CODE (expression) == OFFSET_REF) { + /* Types with dependent vector_size attribute are dependent. */, 0))) + tree a = lookup_attribute ("vector_size", TYPE_ATTRIBUTES (type)); + if (a && ATTR_IS_DEPENDENT (a))D (expression, 1); + return true;ntifier_p (expression)) + return false; /* Other types are non-dependent. */ return false;EF with non-null TREE_TYPE is always non-dependent. */ } @@ -23166,6 +23171,18 @@ type_dependent_expression_p (tree expres if (TREE_CODE (expression) == EXPR_PACK_EXPANSION) return true; + /* Decls where the type is going to have dependent vector_size attribute + are dependent. */ + if (VAR_P (expression) + || TREE_CODE (expression) == PARM_DECL + || TREE_CODE (expression) == RESULT_DECL + || TREE_CODE (expression) == FIELD_DECL) + { + tree a = lookup_attribute ("vector_size", DECL_ATTRIBUTES (expression)); + if (a && ATTR_IS_DEPENDENT (a)) + return true; + } + if (TREE_TYPE (expression) == unknown_type_node) { if (TREE_CODE (expression) == ADDR_EXPR) so far but it didn't make any difference, neither on template <int N> struct D { int v __attribute__((vector_size (N * sizeof (int)))); int f1 () { return this->v[N-1]; } int f2 () { return v[N-1]; } }; int main () { D<4> a = { { 0, 1, 2, 3 } }; D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } }; if (a.f1 () != 3 || a.f2 () != 3 || b.f1 () != 7 || b.f2 () != 7) __builtin_abort (); } nor on template <int N> struct D { typedef int V __attribute__((vector_size (N * sizeof (int)))); V v; int f1 () { return this->v[N-1]; } int f2 () { return v[N-1]; } }; int main () { D<4> a = { { 0, 1, 2, 3 } }; D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } }; if (a.f1 () != 3 || a.f2 () != 3 || b.f1 () != 7 || b.f2 () != 7) __builtin_abort (); }