home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13095 < prev    next >
Encoding:
Text File  |  1992-08-31  |  2.0 KB  |  53 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!think.com!zaphod.mps.ohio-state.edu!cs.utexas.edu!hellgate.utah.edu!fcom.cc.utah.edu!swillden
  3. From: swillden@news.ccutah.edu (Shawn Willden)
  4. Subject: Re: BC++ templates broken
  5. Message-ID: <1992Aug31.155313.5879@fcom.cc.utah.edu>
  6. Sender: news@fcom.cc.utah.edu
  7. Organization: University of Utah Computer Center
  8. X-Newsreader: Tin 1.1 PL3
  9. References: <1992Aug29.212548.8071@fcom.cc.utah.edu>
  10. Date: Mon, 31 Aug 92 15:53:13 GMT
  11. Lines: 40
  12.  
  13. I'm replying to my own post.... (Since there has been an odd and somewhat ominous 
  14. silence in response to my first :-)
  15.  
  16. swillden@news.ccutah.edu (Shawn Willden) writes:
  17. : Hi all,
  18. :     I have discovered a problem with BC++'s templates.  Given code like
  19. : this:
  20. :     template<class T> class A1;
  21. :     template<class T> class A2;
  22. :     
  23. :     template<class T> class A { A1* a; A2* b; };
  24.  
  25. Slight correction here, I meant to say:
  26.     template<class T> class A { A1<T>* a; A2<T>* b;};
  27.  
  28. :     template<class T> class A1 : public A<T> {};
  29. :     template<class T> class A2 : public A<T> {};
  30. :     main() {A1<int> myA1;}
  31. : [stuff deleted]
  32.  
  33. gcc-2.2.2 barfs in the same way and apparently for the same reason.  Except that
  34. BC++ does it gracefully whereas gcc has an "Internal compiler error" and dies.
  35. Am I asking something too difficult?  It seems to me that since A contains only 
  36. *pointers* to objects of type A1<T> and A2<T>, that the compiler should be able to 
  37. say "Oh, okay, this is a pointer to a type that has been forward-declared, I'll 
  38. just make the structure N bytes larger to hold a pointer there and go get the next
  39. token," and not *care* what the expansion is.
  40.  
  41. I think I'm going to take a look at the guts of gcc and see what it would take to
  42. fix it (probably creating another stack of "Templates to expand when I'm done with
  43. my current pile of stuff to do" that will then have to be compared with "Templates
  44. already expanded") but that won't help me with the DOS version (which is the one
  45. that matters).
  46.  
  47. --
  48. Shawn Willden
  49. swillden@icarus.weber.edu
  50.