From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29259 invoked by alias); 20 Jan 2003 23:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 29220 invoked by uid 71); 20 Jan 2003 23:26:01 -0000 Resent-Date: 20 Jan 2003 23:26:01 -0000 Resent-Message-ID: <20030120232601.29219.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, picaud.vincent@wanadoo.fr Received: (qmail 7114 invoked by uid 48); 20 Jan 2003 23:19:31 -0000 Message-Id: <20030120231931.7111.qmail@sources.redhat.com> Date: Mon, 20 Jan 2003 23:26:00 -0000 From: picaud.vincent@wanadoo.fr Reply-To: picaud.vincent@wanadoo.fr To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/9380: nested template problem for methods without argument : parsing error X-SW-Source: 2003-01/txt/msg01127.txt.bz2 List-Id: >Number: 9380 >Category: c++ >Synopsis: nested template problem for methods without argument : parsing error >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Mon Jan 20 23:26:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: picaud.vincent@wanadoo.fr >Release: gcc 3.2.1 >Organization: >Environment: RedHat 7.1, i686 (I have installed the release gcc 3.2.1 without any problem, the original one (RH7.1) was gcc 2.96) >Description: Dear GCC Team, First of all I hope i won't do you waste your time... I use gcc every time in my work and it's a marvelous compiler ! But I think I have found a bug, please consider the short code given in How to Repeat : When I define a method with no argument, like the method "how_many()" I can't use it in a templated function (or class) like with the function foo_2<>(...)... I get a parsing error (before "(") from the compiler. The problem doesn't happen with the function foo_1 (which is not templated). I hope that you will be able to reproduce the problem : for that simply (try to) compile my short example. Regards, >How-To-Repeat: enum topological_dimension { Vertex=0, Edge=1, Face=2, Volume=3, }; template class A { public: template void how_many() const { } }; // This works // Edge for example: Vertex, Face... give the same result void foo_1(const A& a) { a.how_many(); // Vertex for example:Edge, Face... give the same result } // This doesn't work : compiler error :-( (gcc 3.2.1) // template void foo_2(const A& a) { a.how_many(); // <-- Error parsing this line // Vertex for example: Edge, Face...give the same result } main() { } >Fix: To avoid the compilation problem, I use the simple following trick : I introduce an articifial class id_foo<> doing nothing appart being an argument of the function how_many... enum topological_dimension { Vertex=0, Edge=1, Face=2, Volume=3, }; template struct id_foo { }; template class A { public: template void how_many(const id_foo& id) const { } }; // Now, this works... but it's not really convenient... // template void foo_2(const A& a) { a.how_many(id_foo()); // ok... a.how_many(id_foo()); // also ok... } main() { } >Release-Note: >Audit-Trail: >Unformatted: