home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18444 < prev    next >
Encoding:
Text File  |  1992-12-27  |  1.3 KB  |  70 lines

  1. Path: sparky!uunet!spool.mu.edu!uwm.edu!ogicse!news.u.washington.edu!uw-beaver!cornell!moudgill
  2. From: moudgill@cs.cornell.edu ( Mayan Moudgill)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help!!! need a work-around for a bug in cfront 3.0.1
  5. Keywords: cfront 3.0.1, bug, example, workaround, help
  6. Message-ID: <1992Dec27.113136.3320@cs.cornell.edu>
  7. Date: 27 Dec 92 11:31:36 GMT
  8. Article-I.D.: cs.1992Dec27.113136.3320
  9. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  10. Lines: 58
  11.  
  12. I found a bug in cfront 3.0.1. The included program exhibits this
  13. bug. Static functions A<T>::foo() and A<T>::bar() both
  14. call static function B<sizeof(T)>::gah(). gah() prints
  15. out the value of sz i.e. sizeof(T). They turn out to be
  16. different.
  17.  
  18. Has anybody encountered this bug before? Could anybody suggest
  19. a workaround?
  20.  
  21. please,
  22. Please,
  23. PLEASE,
  24. _PLEASE_,
  25. *PLEASE*
  26.  
  27. :(
  28. Mayan
  29. (moudgill@cs.cornell.edu)
  30.  
  31. ------------------------- CUT HERE ----------------------------
  32. #include <iostream.h>
  33.  
  34. template<class T>
  35. class A {
  36. public:
  37.    static int foo();
  38.    static int bar();
  39. };
  40.  
  41. template<unsigned sz>
  42. class B {
  43. public:
  44.    static
  45.    int gah()
  46.       {
  47.          cerr << sz << endl;
  48.      return 0;
  49.       }
  50. };
  51.  
  52.  
  53. template<class T>
  54. int A<T>::foo()
  55. {
  56.    return B<sizeof(T)>::gah();
  57. }
  58.  
  59. template<class T>
  60. int A<T>::bar()
  61. {
  62.    return B<sizeof(T)>::gah();
  63. }
  64.  
  65. main()
  66. {
  67.    A<double>::foo();
  68.    A<double>::bar();
  69. }
  70.