public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc-3.4 requires 'typename' to use map in a template?
@ 2003-10-02 23:56 Dan Kegel
  2003-10-03  0:39 ` Dan Kegel
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Kegel @ 2003-10-02 23:56 UTC (permalink / raw)
  To: gcc

The following code is rejected by gcc-3.4-20031001, but accepted
by gcc-2.95 and gcc-3.2.3:

#include <map>

template <typename T>
class myclass {
         typedef std::map<T, unsigned int> mymap;
public:
         void mymethod() {
             mymap::iterator myvar;
             myvar = 0;
         }
};

Command to reproduce:
$ /usr/local/gcc-3.4-20031001/bin/g++ foo2.cc
foo2.cc: In member function `void myclass<T>::mymethod()':
foo2.cc:8: error: expected `;'
foo2.cc:9: error: `myvar' undeclared (first use this function)

Using the typename keyword seems to be a workaround, as
gcc-3.4-20031001 accepts the following code without complaint:

#include <map>

template <typename T>
class myclass {
         typedef std::map<T, unsigned int> mymap;
public:
         void mymethod() {
             typename mymap::iterator myvar;
             myvar = 0;
         }
};

So is gcc-3.4-20031001 right to require typename here, or is this a bug?
- Dan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-03  0:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-02 23:56 gcc-3.4 requires 'typename' to use map in a template? Dan Kegel
2003-10-03  0:39 ` Dan Kegel
2003-10-03  0:51   ` David Carlton
2003-10-03  0:59     ` Dan Kegel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).