This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: template breakage
- To: jason at cygnus dot com
- Subject: Re: template breakage
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Thu, 28 May 1998 15:35:26 -0700
- CC: g++-local at cygnus dot com, Nathan Myers <ncm at cantrip dot org>, egcs-patches at cygnus dot com
- References: <199805280710.AAA16131@yorick.cygnus.com>
- Reply-to: mark at markmitchell dot com
Jason --
Here's a fix, I think. The test here did not match the
corresponding comment; it didn't even before I made my changes, but
my change unmasked this bug. OK to check in?
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-05-28 Mark Mitchell <mark@markmitchell.com>
* pt.c (instantiate_decl): Make test for whether or not static
variables should be instantiated early match its comment.
Index: static3.C
===================================================================
RCS file: static3.C
diff -N static3.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- static3.C Thu May 28 15:24:37 1998
***************
*** 0 ****
--- 1,12 ----
+ template<class T>
+ struct A {
+ static T arr[5];
+ };
+
+ template <class T>
+ T A<T>::arr[5] = { 0, 1, 2, 3, 4 };
+
+ main ()
+ {
+ return A<int>::arr[0];
+ }
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.147
diff -c -p -r1.147 pt.c
*** pt.c 1998/05/27 19:11:33 1.147
--- pt.c 1998/05/28 22:25:19
*************** instantiate_decl (d)
*** 7141,7146 ****
--- 7141,7147 ----
goto out;
if (TREE_CODE (d) == VAR_DECL
+ && TREE_READONLY (d)
&& DECL_INITIAL (d) == NULL_TREE
&& DECL_INITIAL (code_pattern) != NULL_TREE)
/* We need to set up DECL_INITIAL regardless of pattern_defined if