public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11711] New: Inheritance from partially specialized template does not work
@ 2003-07-29 19:12 furnish at lightspeed dot com
  2003-07-29 20:37 ` [Bug c++/11711] " mmitchel at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: furnish at lightspeed dot com @ 2003-07-29 19:12 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=11711

           Summary: Inheritance from partially specialized template does not
                    work
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: furnish at lightspeed dot com
                CC: gcc-bugs at gcc dot gnu dot org

The following code will not compile under GCC 3.3, 3.3.1 (prerelease,
2003/07/20 snapshot), or 3.4 (cvs head as of 2003/07/29).

template<class H, class T> struct TL {};

template<class X> class Base;

template<class H, class T>
class Base< TL<H,T> >
{
  public:
    template<int I> void f() {}
};

template<class H, class T>
class Derived
    : public Base< TL<H,T> >
{
  public:
    void g()
    {
        f<1>();
    }
};

KCC 4.0f --strict compiles this code, which is some evidence that the code
is in fact legal.  The problem seems to be that class Derived isn't actually
inheriting from the specialized Base variant, or at least, name lookup
is failing to find the (template) member function f().


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

* [Bug c++/11711] Inheritance from partially specialized template does not work
  2003-07-29 19:12 [Bug c++/11711] New: Inheritance from partially specialized template does not work furnish at lightspeed dot com
@ 2003-07-29 20:37 ` mmitchel at gcc dot gnu dot org
  2003-07-29 21:37 ` furnish at lightspeed dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2003-07-29 20:37 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=11711


mmitchel at gcc dot gnu dot org changed:

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


------- Additional Comments From mmitchel at gcc dot gnu dot org  2003-07-29 20:36 -------
This is correct behavior per the standard.  

The base class is dependent; therefore name lookup does look into the base 
class.

See gcc/doc/trouble.texi for more information.


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

* [Bug c++/11711] Inheritance from partially specialized template does not work
  2003-07-29 19:12 [Bug c++/11711] New: Inheritance from partially specialized template does not work furnish at lightspeed dot com
  2003-07-29 20:37 ` [Bug c++/11711] " mmitchel at gcc dot gnu dot org
@ 2003-07-29 21:37 ` furnish at lightspeed dot com
  2003-07-29 21:43 ` pinskia at physics dot uc dot edu
  2003-08-01 10:57 ` pinskia at physics dot uc dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: furnish at lightspeed dot com @ 2003-07-29 21:37 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=11711


furnish at lightspeed dot com changed:

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


------- Additional Comments From furnish at lightspeed dot com  2003-07-29 21:37 -------
I stand corrected.  And thanks for pointing me to the explanation, as it was
good to be reminded of that.

However, if I make the suggested correction to the call site to make
the reference dependent, GCC still fails to compile the (corrected) code.

For example, if we try

template<class H, class T>
class Derived
    : public Base< TL<H,T> >
{
  public:
    void g()
    {
        this->f<1>();
    }
};

Then gcc 3.3.1 (prerelease) gives:
/opt/gcc-3.3.1/bin/c++ -v -c x.cc
Reading specs from /opt/gcc-3.3.1/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/specs
Configured with: ./configure --prefix=/opt/gcc-3.3.1 : (reconfigured)
./configure --prefix=/opt/gcc-3.3.1 --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.3.1 20030720 (prerelease)
...
x.cc: In member function `void Derived<H, T>::g()':
x.cc:20: error: parse error before `;' token

which I think is the same error message as before, and gcc 3.4 (cvs head) gives:

/opt/gcc-3.4/bin/c++ -v -c x.cc
Reading specs from /opt/gcc-3.4/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ./configure --prefix=/opt/gcc-3.4 : (reconfigured) ./configure
--prefix=/opt/gcc-3.4 --enable-languages=c,c++,f77,java
Thread model: posix
gcc version 3.4 20030729 (experimental)
...
x.cc: In member function `void Derived<H, T>::g()':
x.cc:20: error: expected primary-expression


Similarly, if we qualify the call site in this way:
template<class H, class T>
class Derived
    : public Base< TL<H,T> >
{
  public:
    void g()
    {
        Base< TL<H,T> >::f<1>();
    }
};

which if I understand the trouble.texi correctly, should also be a legal way
to introduce the dependency, then it still fails to compile with the same
errors as with this->, quoted above, for all versions of gcc 3.2 through 3.4.

Consequently, I am reopening the bug.


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

* [Bug c++/11711] Inheritance from partially specialized template does not work
  2003-07-29 19:12 [Bug c++/11711] New: Inheritance from partially specialized template does not work furnish at lightspeed dot com
  2003-07-29 20:37 ` [Bug c++/11711] " mmitchel at gcc dot gnu dot org
  2003-07-29 21:37 ` furnish at lightspeed dot com
@ 2003-07-29 21:43 ` pinskia at physics dot uc dot edu
  2003-08-01 10:57 ` pinskia at physics dot uc dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-29 21:43 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=11711


pinskia at physics dot uc dot edu changed:

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


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-29 21:43 -------
With icc 6.0 in strict mode (-Xc) icc rejects this after adding this-> or Base< TL<H,T> >:: before 
f<1>.
The code is still invalid as f is template but the standard says it is not a template so adding 
template in front of f<1> fixes it.
template<class H, class T>
class Derived
    : public Base< TL<H,T> >
{
  public:
    void g()
    {
        Base< TL<H,T> >::template f<1>(); // or this->template  f<1>();
    }
};


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

* [Bug c++/11711] Inheritance from partially specialized template does not work
  2003-07-29 19:12 [Bug c++/11711] New: Inheritance from partially specialized template does not work furnish at lightspeed dot com
                   ` (2 preceding siblings ...)
  2003-07-29 21:43 ` pinskia at physics dot uc dot edu
@ 2003-08-01 10:57 ` pinskia at physics dot uc dot edu
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-01 10:57 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=11711


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pgonzalez at bluel dot com


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-01 10:57 -------
*** Bug 11759 has been marked as a duplicate of this bug. ***


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

end of thread, other threads:[~2003-08-01 10:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 19:12 [Bug c++/11711] New: Inheritance from partially specialized template does not work furnish at lightspeed dot com
2003-07-29 20:37 ` [Bug c++/11711] " mmitchel at gcc dot gnu dot org
2003-07-29 21:37 ` furnish at lightspeed dot com
2003-07-29 21:43 ` pinskia at physics dot uc dot edu
2003-08-01 10:57 ` pinskia at physics dot uc dot edu

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