From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2829 invoked by alias); 30 Apr 2002 21:46:03 -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 2784 invoked by uid 71); 30 Apr 2002 21:46:01 -0000 Resent-Date: 30 Apr 2002 21:46:01 -0000 Resent-Message-ID: <20020430214601.2783.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, oliver.schoenborn@utoronto.ca Received:(qmail 31299 invoked from network); 30 Apr 2002 21:38:56 -0000 Received: from unknown (HELO onyx1.imti.nrc.ca) (198.20.44.73) by sources.redhat.com with SMTP; 30 Apr 2002 21:38:56 -0000 Received: (from root@localhost) by onyx1.imti.nrc.ca (SGI-8.9.3/8.9.3) id RAA70792; Tue, 30 Apr 2002 17:39:55 -0400 (EDT) Message-Id:<200204302139.RAA70792@onyx1.imti.nrc.ca> Date: Tue, 30 Apr 2002 14:46:00 -0000 From: Oliver Schoenborn Reply-To: oliver.schoenborn@utoronto.ca To: gcc-gnats@gcc.gnu.org Cc: oliver.schoenborn@utoronto.ca X-Send-Pr-Version:3.113 Subject: c++/6523: bug with pointers to template functions X-SW-Source: 2002-04/txt/msg01658.txt.bz2 List-Id: >Number: 6523 >Category: c++ >Synopsis: bug with pointers to template functions >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: ice-on-legal-code >Submitter-Id: net >Arrival-Date: Tue Apr 30 14:46:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Oliver Schoenborn >Release: 3.0.1 >Organization: >Environment: System: IRIX64 onyx1 6.5 07091542 IP27 host: mips-sgi-irix6.5 build: mips-sgi-irix6.5 target: mips-sgi-irix6.5 configured with: ../configure --prefix=/usr/freeware --enable-version-specific-runtime-libs --disable-shared --enable-threads --enable-haifa >Description: Note that I built g++ 3.0.4 on my home linux system (Mandrake 8.1) and got same compiler failure so it is unlikely to be related to environment. Output from g++ is following: funcPtrProblem.cc: In function `int main()': funcPtrProblem.cc:32: Internal compiler error in c_expand_expr, at c-common.c: 4121 A class Tester defines a function pointer typedef BarFunc and an example static function template of that type, called bar(). Two different class templates Foo1 and Foo2 each have a /templated/ constructor (ie Foo1::Foo1) that use a pointer to the bar() template function. One Foo accesses this bar via inheritence, i.e. Foo2 inherits from Tester. The other, Foo1, accesses it directly since it is static and public. In other words, both Foo classes do exactly the same thing (semantically) but in different ways. Foo2 causes compiler crash. Compilation works if constructor of Foo2 is not templated, or even if it is but Foo2 itself is not a class template, or if bar is not a template. >How-To-Repeat: Put following code in one file called funcPtrProblem.cc and do g++ -c funcPtrProblem.cc to get the above internal compiler error struct Tester { typedef void (*BarFunc)(); template static void bar() {} }; template struct Foo1 { template Foo1(T2*, Tester::BarFunc = &Tester::bar) {} }; template struct Foo2: private Tester { template Foo2(T2*, BarFunc = &bar) {} }; int main() { Foo1 foo1(new int); Foo2 foo2(new int); } >Fix: Do not use inheritence. This means that Tester must have everything public >Release-Note: >Audit-Trail: >Unformatted: