This is the mail archive of the gcc-patches@gcc.gnu.org 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 Jason.

> 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?

Thanks in advance.

Best regards,
Simon
2006-08-26  Simon Martin  <simartin@users.sourceforge.net>

	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
 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:
 
2006-08-26  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/28284
	* g++.dg/template/pr28284.cpp: 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]