c++/4030: stupid warning message about template type

khlebnikov@scnsoft.com khlebnikov@scnsoft.com
Wed Aug 15 05:36:00 GMT 2001


>Number:         4030
>Category:       c++
>Synopsis:       stupid warning message about template type
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 15 05:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     g++
>Release:        3.0.1pre20010801, 3.0 release, 2.95.4pre20010319
>Organization:
>Environment:
Intel Pentium II
Progeny Debian 1.0
GCC:
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.1/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.0.1 20010801 (Debian prerelease)
>Description:
$ g++-3.0 -c error.cpp 
error.cpp:13: warning: lookup of `_TN' finds `class _TN'
error.cpp:13: warning:   instead of `typename B<_NY, _TN>::_TN' from dependent 
   base class
error.cpp:13: warning:   (use `typename B::_TN' if that's what you meant)
===============================================
I use type _TN in class B and I must refer to it
as "B::_TN" ?
>How-To-Repeat:
template <class _TTN, class _TNK>
class A
{
//public:
private:
	typedef _TTN _TN;
};


template <class _NY, class _TN>
class B : virtual public A <_TN, _NY>
{
	_TN func () = 0;
};
>Fix:
1) Do not typedef _TN (even private!) in the base class.
2) Instead of "_TN func () = 0;", write "B::_TN func () = 0;"
   (imagine that the name of class is 20 symbols long and
   you use type _TN 20 tymes).
3) Instead of "template <class _NY, class _TN>", write
   "template <class _TN, class _NY>", i.e. displace types
   in declaration.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="error.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="error.cpp"

dGVtcGxhdGUgPGNsYXNzIF9UVE4sIGNsYXNzIF9UTks+CmNsYXNzIEEKewovL3B1YmxpYzoKcHJp
dmF0ZToKCXR5cGVkZWYgX1RUTiBfVE47Cn07CgoKdGVtcGxhdGUgPGNsYXNzIF9OWSwgY2xhc3Mg
X1ROPgpjbGFzcyBCIDogdmlydHVhbCBwdWJsaWMgQSA8X1ROLCBfTlk+CnsKCV9UTiBmdW5jICgp
ID0gMDsKfTsK



More information about the Gcc-bugs mailing list