This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

-pedantic -> type is no longer a type in 19990131



A file containing nothing but the following code:

---------------------------------------------------------------------------
#include <vector>

using std::vector;

template <class T>
class TPVector : public vector<T *>
{
    typedef vector<int *>::const_iterator iptype;
    typedef vector<T *>::const_iterator tptype;
};
---------------------------------------------------------------------------

compiles cleanly with both egcs 1.1.1 and the 19990131 snapshot (and
subsequent code does exactly what you'd expect).

However, if I compile with -pedantic on, I get told for the second typedef:


    warning: ANSI C++ forbids typedef which does not specify a type
    cannot declare member `vector<T *,__default_alloc_template<true,0> >::const_iterator' within `TPVector<T>'
    parse error before `;'


I am at a complete loss as to why 'vector<T *>::const_iterator' should,
within this context, not be considered a type, even if only pedantically.
Surely, within the scope of the template parameter T, the second typedef
should be no different from the first typedef?

Consequently, I am submitting this as a possible compiler problem -- I
apologise beforehand if the problem is with my lack of understanding of C++
or templates instead, in which case I would be most grateful for
enlightenment in e-mail.

Cheers,

-- 
Leo Breebaart  <leo@lspace.org>


--------------------------------------------------------------------------
/usr/local/bin/g++ -v -pedantic -c type-err.cc
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/specs
gcc version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=93 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -pedantic -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ type-err.cc /tmp/ccELpAgv.ii
GNU CPP version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/../../../../include/g++-2
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/../../../../i686-pc-linux-gnu/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.93.04/cc1plus /tmp/ccELpAgv.ii -quiet -dumpbase type-err.cc -pedantic -version -o /tmp/ccgVA8x3.s
GNU C++ version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.93.04 19990131 (gcc2 ss-980929 experimental).
type-err.cc:9: warning: ANSI C++ forbids declaration `const_iterator' with no type
type-err.cc:9: cannot declare member `vector<T *,allocator<T *> >::const_iterator' within `TPVector<T>'
type-err.cc:9: parse error before `;'
---------------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]