public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: ronny@mit.edu
To: gcc-gnats@gcc.gnu.org
Subject: c++/7345: parse error when using templated member function from templated base class
Date: Wed, 17 Jul 2002 12:46:00 -0000	[thread overview]
Message-ID: <20020717194527.25853.qmail@sources.redhat.com> (raw)


>Number:         7345
>Category:       c++
>Synopsis:       parse error when using templated member function from templated base class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 17 12:46:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ronny Krashinsky
>Release:        gcc version 3.0.4
>Organization:
>Environment:
x86, linux
>Description:
compiling this program:
-----------------------------------------------------
//#include<stdio.h>

template<int x>
class A {
public:
  template<int y>
  int foo() { return (x + y); };
  int foo2() { return foo<2>(); };
};


template<int x>
class B : public A<x> {
public:
  int bar() { 
    return ( foo<2>() );
  };
};


int main() {
  int i;
  A<3> a;
  i = a.foo<2>();
  //printf("%d\n", i);
  i = a.foo2();
  //printf("%d\n", i);

  B<3> b;
  i = b.bar();
  //printf("%d\n", i);

  return(0);
};
-----------------------------------------------------

results in this parse error:
-----------------------------------------------------
bug.cc: In member function `int B<x>::bar()':
bug.cc:16: parse error before `;' token
-----------------------------------------------------

I think that the compiler is not recognizing foo<2> as the name of a function as it should.

I don't know of any workaround to call foo<2> from within B.  "A::foo<2>()" doesn't work, "using A::foo<2>" doesn't work, declaring a function pointer doesn't work, etc.
>How-To-Repeat:
compile the program
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.cc"

Ly8jaW5jbHVkZTxzdGRpby5oPgoKdGVtcGxhdGU8aW50IHg+CmNsYXNzIEEgewpwdWJsaWM6CiAg
dGVtcGxhdGU8aW50IHk+CiAgaW50IGZvbygpIHsgcmV0dXJuICh4ICsgeSk7IH07CiAgaW50IGZv
bzIoKSB7IHJldHVybiBmb288Mj4oKTsgfTsKfTsKCgp0ZW1wbGF0ZTxpbnQgeD4KY2xhc3MgQiA6
IHB1YmxpYyBBPHg+IHsKcHVibGljOgogIGludCBiYXIoKSB7IAogICAgcmV0dXJuICggZm9vPDI+
KCkgKTsKICB9Owp9OwoKCmludCBtYWluKCkgewogIGludCBpOwogIEE8Mz4gYTsKICBpID0gYS5m
b288Mj4oKTsKICAvL3ByaW50ZigiJWRcbiIsIGkpOwogIGkgPSBhLmZvbzIoKTsKICAvL3ByaW50
ZigiJWRcbiIsIGkpOwoKICBCPDM+IGI7CiAgaSA9IGIuYmFyKCk7CiAgLy9wcmludGYoIiVkXG4i
LCBpKTsKCiAgcmV0dXJuKDApOwp9OwoKCgoKCg==


             reply	other threads:[~2002-07-17 19:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-17 12:46 ronny [this message]
2002-07-20  9:13 lerdsuwa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020717194527.25853.qmail@sources.redhat.com \
    --to=ronny@mit.edu \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).