home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!cs.utexas.edu!usc!rpi!batcomputer!cornell!moudgill
- From: moudgill@cs.cornell.edu ( Mayan Moudgill)
- Subject: Is there a workaround for this bug?
- Message-ID: <1992Nov20.221252.653@cs.cornell.edu>
- Summary: parser bug for templates
- Keywords: template, bug, example, 3.01
- Organization: Cornell Univ. CS Dept, Ithaca NY 14853
- Date: Fri, 20 Nov 1992 22:12:52 GMT
- Lines: 67
-
- I discovered what appears to be a bug in the AT&T C++ 3.01 compiler.
- I've included two files which demonstrate it. The first one compiles
- correctly, the second doesn't. Both files declare a particular inline
- function. The first one defines it inside the class, and it compiles
- correctly. The second defines it below the class, and it does not compile.
- If it *IS* a bug, who should I report it to.
-
- *Please* reply be e-mail. Thanks,
- :)
- Mayan
-
- ------------- CUT HERE FOR CORRECT PROGRAM -------------------
- template <unsigned sz> class Vector;
- template <unsigned sz> class VectorBind;
-
- template <unsigned sz>
- class VectorBind {
- public:
- inline VectorBind()
- {
- }
- };
-
- template <unsigned sz>
- class Vector {
- public:
- inline VectorBind<sz> operator [] (unsigned)
- {
- return VectorBind<sz>();
- }
- };
-
- main()
- {
- Vector<16u> v;
- (void)v[8];
- }
-
- ------------- CUT HERE FOR INCORRECT PROGRAM -------------------
- template <unsigned sz> class Vector;
- template <unsigned sz> class VectorBind;
-
- template <unsigned sz>
- class VectorBind {
- public:
- inline VectorBind()
- {
- }
- };
-
- template <unsigned sz>
- class Vector {
- public:
- inline VectorBind<sz> operator [] (unsigned);
- };
-
- template <unsigned sz>
- inline VectorBind<sz> Vector<sz>::operator [] (unsigned val)
- {
- return VectorBind<sz>();
- }
-
- main()
- {
- Vector<16u> v;
- (void)v[8];
- }
-