public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Oliver Schoenborn <oliver@onyx1.imti.nrc.ca> To: gcc-gnats@gcc.gnu.org Cc: oliver.schoenborn@utoronto.ca Subject: c++/6523: bug with pointers to template functions Date: Tue, 30 Apr 2002 14:46:00 -0000 [thread overview] Message-ID: <200204302139.RAA70792@onyx1.imti.nrc.ca> (raw) >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<T>(). Two different class templates Foo1<T> and Foo2<T> each have a /templated/ constructor (ie Foo1<T>::Foo1<T2>) that use a pointer to the bar<T2>() template function. One Foo accesses this bar<T> 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 <typename T> static void bar() {} }; template <typename T> struct Foo1 { template <typename T2> Foo1(T2*, Tester::BarFunc = &Tester::bar<T2>) {} }; template <typename T> struct Foo2: private Tester { template <typename T2> Foo2(T2*, BarFunc = &bar<T2>) {} }; int main() { Foo1<int> foo1(new int); Foo2<int> foo2(new int); } >Fix: Do not use inheritence. This means that Tester must have everything public >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-04-30 21:46 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-30 14:46 Oliver Schoenborn [this message] 2002-05-15 6:43 lerdsuwa 2002-05-27 7:56 Reichelt 2002-05-27 20:55 Oliver Schoenborn
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=200204302139.RAA70792@onyx1.imti.nrc.ca \ --to=oliver@onyx1.imti.nrc.ca \ --cc=gcc-gnats@gcc.gnu.org \ --cc=oliver.schoenborn@utoronto.ca \ /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: linkBe 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).