public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11429] New: nested class within template class is not inherited by derived template class
@ 2003-07-04  5:50 pettit at mbi dot ucla dot edu
  2003-07-04  5:52 ` [Bug c++/11429] " pettit at mbi dot ucla dot edu
  2003-07-04 20:45 ` bangerth at dealii dot org
  0 siblings, 2 replies; 3+ messages in thread
From: pettit at mbi dot ucla dot edu @ 2003-07-04  5:50 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11429

           Summary: nested class within template class is not inherited by
                    derived template class
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pettit at mbi dot ucla dot edu
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Gcc 3.3 emits nonsensical "implicit typename" warnings whenever a derived 
template class mentions a nested class that was declared within the 
base template class; the nested class should be inherited by the derived 
class, but is not inherited. Hence gcc regards any mention of the nested
class as an "implicit typename". Does not happend with Gcc 2.96, but
I remember it happening with earlier versions.
Here is a simple example (warning message listed below):

template < class T>
class base
{
public:
  base( void) { }
  ~base( void)  { }
  class nested
  {
  public:
    int i;
  };
};

template < class T>
class derived : public base< T >
{
public:
  derived( void)  { }
  ~derived( void)  { }
  int transform( nested f1st, nested last) const;
};

template < class T>
int derived< T>::transform( derived< T>::nested f1st,
			    derived< T>::nested last) const
{ return f1st.i+last.i; }

int main( int argc, char **argv)
{
  int j;
  base<int>    bob;
  derived<int> mary;
  derived<int>::nested f1st, last;
  f1st.i = 2;
  last.i = 2;
  j = mary.transform( f1st, last);
}

template class base< int>;
template class derived< int>;

Here is the warning message from GCC:

junk.cpp:20: warning: `derived<T>::nested' is implicitly a typename
junk.cpp:20: warning: implicit typename is deprecated, please see the
   documentation for details
junk.cpp:20: warning: `derived<T>::nested' is implicitly a typename
junk.cpp:20: warning: implicit typename is deprecated, please see the
   documentation for details
junk.cpp:26: warning: `derived<T>::nested' is implicitly a typename
junk.cpp:26: warning: implicit typename is deprecated, please see the
   documentation for details
junk.cpp:26: warning: `derived<T>::nested' is implicitly a typename
junk.cpp:26: warning: implicit typename is deprecated, please see the
   documentation for details

Gcc was configured with these options:

Configured with: ../gcc-3.3/configure --with-stabs --with-as=/usr/bin/as
--with-ld=/usr/bin/ld --enable-languages=c,c++,f77,java --enable-threads=posix
Thread model: posix
gcc version 3.3

Output of uname -a:
Linux 2.4.3-20mdk #1 Sun Apr 15 23:03:10 CEST 2001 i686 unknown


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

* [Bug c++/11429] nested class within template class is not inherited by derived template class
  2003-07-04  5:50 [Bug c++/11429] New: nested class within template class is not inherited by derived template class pettit at mbi dot ucla dot edu
@ 2003-07-04  5:52 ` pettit at mbi dot ucla dot edu
  2003-07-04 20:45 ` bangerth at dealii dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pettit at mbi dot ucla dot edu @ 2003-07-04  5:52 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11429



------- Additional Comments From pettit at mbi dot ucla dot edu  2003-07-04 05:52 -------
Created an attachment (id=4346)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4346&action=view)
simple source for testing


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

* [Bug c++/11429] nested class within template class is not inherited by derived template class
  2003-07-04  5:50 [Bug c++/11429] New: nested class within template class is not inherited by derived template class pettit at mbi dot ucla dot edu
  2003-07-04  5:52 ` [Bug c++/11429] " pettit at mbi dot ucla dot edu
@ 2003-07-04 20:45 ` bangerth at dealii dot org
  1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2003-07-04 20:45 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11429


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From bangerth at dealii dot org  2003-07-04 20:45 -------
This is not a bug, but warns you correctly of invalid code: if
you use identifiers such as "nested" in the derived class, then
they are implicitly typenames of the form 
  typename base<T>::nested
The point is that the standard prescribes that names from template
dependent base classes are not visible during lookup, so your
code is invalid and will not even compile with gcc3.4. You
really need to write
  typename base<T>::nested
instead.

Wolfgang


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

end of thread, other threads:[~2003-07-04 20:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-04  5:50 [Bug c++/11429] New: nested class within template class is not inherited by derived template class pettit at mbi dot ucla dot edu
2003-07-04  5:52 ` [Bug c++/11429] " pettit at mbi dot ucla dot edu
2003-07-04 20:45 ` bangerth at dealii dot org

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).