2006-12-08 Alexandre Oliva * g++.dg/template/array17.C: New test. 2006-10-27 Alexandre Oliva * typeck.c (non_reference): Don't dereference NULL type. --- gcc/cp/typeck.c.orig 2005-11-21 11:56:03.000000000 -0200 +++ gcc/cp/typeck.c 2006-10-27 03:28:04.000000000 -0300 @@ -6443,7 +6443,7 @@ casts_away_constness (tree t1, tree t2) tree non_reference (tree t) { - if (TREE_CODE (t) == REFERENCE_TYPE) + if (t != NULL_TREE && TREE_CODE (t) == REFERENCE_TYPE) t = TREE_TYPE (t); return t; } --- gcc/testsuite/g++.dg/template/array17.C 2006-10-04 16:28:56.502613000 +0200 +++ gcc/testsuite/g++.dg/template/array17.C 2006-12-08 12:38:27.000000000 +0100 @@ -0,0 +1,23 @@ +// { dg-do compile } + +template +struct V { + T& operator[](int); +}; + +struct S { + S operator +(int); + template T value(); +}; + +template +void R (T v) +{ + v[(S() + 0).template value()][0] = 0; +} + +int +main () +{ + R(V >()); +}