From: Simon Martin Date: Thu, 7 Sep 2006 17:25:05 +0000 (+0000) Subject: re PR c++/28284 (ICE with invalid static const variable) X-Git-Tag: releases/gcc-4.2.0~1499 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4a200d359866bc4d8dd1e9ef71cdbc69ab80b74;p=thirdparty%2Fgcc.git re PR c++/28284 (ICE with invalid static const variable) PR c++/28284 * pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if it is NULL. From-SVN: r116755 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6da5e29a34a..6d590239f4ea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-09-07 Simon Martin + + PR c++/28284 + * pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if it + is NULL. + 2006-09-06 Zak Kipling PR c++/26195 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 715b9461aba4..aea943ed0c18 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3410,6 +3410,9 @@ redeclare_class_template (tree type, tree parms) tree fold_non_dependent_expr (tree expr) { + if (expr == NULL_TREE) + return NULL_TREE; + /* If we're in a template, but EXPR isn't value dependent, simplify it. We're supposed to treat: diff --git a/gcc/testsuite/g++.dg/template/pr28284.C b/gcc/testsuite/g++.dg/template/pr28284.C new file mode 100644 index 000000000000..7ef9aa12b2b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr28284.C @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +template struct A +{ + static const int i=x; /* { dg-error "was not declared in this scope" } */ + static const int j, k; +}; + +template const int A::j = i; +template const int A::k = j; + +A<0> a;