public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30657]  New: template class derived from template class does not access base class' members
@ 2007-01-31 18:10 paolo dot greppi at tiscali dot it
  2007-01-31 18:16 ` [Bug c++/30657] " pinskia at gcc dot gnu dot org
  2007-02-01 18:08 ` paolo dot greppi at tiscali dot it
  0 siblings, 2 replies; 3+ messages in thread
From: paolo dot greppi at tiscali dot it @ 2007-01-31 18:10 UTC (permalink / raw)
  To: gcc-bugs

Listing 1 compiles fine:
class smallclass {
public:
  int uu;
  smallclass(void) : uu(1) { }
};

class largeclass : public smallclass {
public:
  int *uup;
  void test(void) { uup = &(smallclass::uu); }
};

int main () {
  largeclass a;
  a.test();
}

Listing 2 fails:
template <class E> class smallclass {
public:
  E uu;
  smallclass(void) : uu(1) { }
}; // class smallclass

template <class E> class largeclass : public smallclass<E> {
public:
  E *uup;
  void test(void) { uup = &(uu); }
};

int main () {
  largeclass<int> a;
  a.test();
}
The error on compile on both gcc-4.0.1 and 3.4.1 is:
'uu' was not declared in this scope or `uu' undeclared

If one tries to fix it like this:
  void test(void) { uup = &(smallclass<E>::uu); }
the error on both gcc-4.0.1 and 3.4.1 becomes:
error: cannot convert 'int smallclass<int>::*' to 'int*' in assignment

All code compiles fine on:
- Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86 (Visual Studio 2005)
- cxx (v6.5 su Tru64/alpha) 
- aCC (vA.5.55 per HP-UX/Itanium)
- intel cc 9.0
- gcc 3.2 and 3.3
- Comeau C++ 4.3.3


-- 
           Summary: template class derived from template class does not
                    access base class' members
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paolo dot greppi at tiscali dot it
 GCC build triplet: i686-pc-cygwin
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin


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


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

* [Bug c++/30657] template class derived from template class does not access base class' members
  2007-01-31 18:10 [Bug c++/30657] New: template class derived from template class does not access base class' members paolo dot greppi at tiscali dot it
@ 2007-01-31 18:16 ` pinskia at gcc dot gnu dot org
  2007-02-01 18:08 ` paolo dot greppi at tiscali dot it
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-31 18:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-01-31 18:16 -------
And all the other compilers are incorrect as uu is not dependent so it is
looked up during parsing and not during instatintation.

The correct fix for this is to make it dependent like &(this->uu) instead.

Please read:
http://gcc.gnu.org/gcc-3.4/changes.html


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/30657] template class derived from template class does not access base class' members
  2007-01-31 18:10 [Bug c++/30657] New: template class derived from template class does not access base class' members paolo dot greppi at tiscali dot it
  2007-01-31 18:16 ` [Bug c++/30657] " pinskia at gcc dot gnu dot org
@ 2007-02-01 18:08 ` paolo dot greppi at tiscali dot it
  1 sibling, 0 replies; 3+ messages in thread
From: paolo dot greppi at tiscali dot it @ 2007-02-01 18:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot greppi at tiscali dot it  2007-02-01 18:07 -------
Thank you very much, I am now going ahead and filing the bug reports for the
other compilers :-)


-- 

paolo dot greppi at tiscali dot it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |VERIFIED


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


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

end of thread, other threads:[~2007-02-01 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-31 18:10 [Bug c++/30657] New: template class derived from template class does not access base class' members paolo dot greppi at tiscali dot it
2007-01-31 18:16 ` [Bug c++/30657] " pinskia at gcc dot gnu dot org
2007-02-01 18:08 ` paolo dot greppi at tiscali dot it

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