This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR c++/28284: ICE with invalid static const variable

Hi again.

> > I'd prefer to check for NULL in fold_non_dependent_expr, rather than in
> > the caller.
> Here's the revised patch, bootstrapped and regtested on i686-pc-linux-gnu.
> Could you please apply it if it is OK?
I've just figured out that the testcase I provided with a "cpp" extension was 
not taken into account when regtesting. I've therefore changed the extension 
to "C", which fixes the problem. Here's the (hopefully) final version of this 

Sorry for the inconvenience.

Best regards,
2006-08-27  Simon Martin  <>

	PR c++/28284
	* pt.c (fold_non_dependent_expr): Make sure expr is not dereferenced if it
	is NULL.
Index: gcc/cp/pt.c
--- gcc/cp/pt.c	(revision 116469)
+++ gcc/cp/pt.c	(working copy)
@@ -3387,6 +3387,9 @@ redeclare_class_template (tree type, tre
 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:
2006-08-27  Simon Martin  <>

	PR c++/28284
	* g++.dg/template/pr28284.C: New test.
/* { dg-do compile } */

template<int> struct A
  static const int i=x; /* { dg-error "was not declared in this scope" } */
  static const int j, k;

template<int N> const int A<N>::j = i;
template<int N> const int A<N>::k = j;

A<0> a;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]