public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6523: bug with pointers to template functions
@ 2002-04-30 14:46 Oliver Schoenborn
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Schoenborn @ 2002-04-30 14:46 UTC (permalink / raw)
To: gcc-gnats; +Cc: oliver.schoenborn
>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:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/6523: bug with pointers to template functions
@ 2002-05-27 20:55 Oliver Schoenborn
0 siblings, 0 replies; 4+ messages in thread
From: Oliver Schoenborn @ 2002-05-27 20:55 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/6523; it has been noted by GNATS.
From: Oliver Schoenborn <oliver.schoenborn@utoronto.ca>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
reichelt@igpm.rwth-aachen.de, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org
Cc:
Subject: Re: c++/6523: bug with pointers to template functions
Date: Mon, 27 May 2002 21:34:50 -0400
> From: Reichelt <reichelt@igpm.rwth-aachen.de>
> To: gcc-gnats@gcc.gnu.org, oliver.schoenborn@utoronto.ca, gcc-bugs@gcc.gnu.org,
> nobody@gcc.gnu.org
> Subject: Re: c++/6523: bug with pointers to template functions
> Date: Mon, 27 May 2002 16:49:49 +0200
>
> Hi,
>
> the example can be reduced to the one in PR 4249.
> Therefore, the PR can probably be closed.
>
> Greetings,
> Volker Reichelt
>
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6523
>
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4249
It's not clear to me that 6523 can be reduced to 4249, unless someone
knows what *causes* the bug. Indeed, my example Foo1 class (see bug
report 6523 abnove) is similar to 4249 example, IT actually compiles
fine, it is the *Foo2* class example that causes compiler to crash on
the g++ source file. That one does NOT reduce to 4249 (AFAICT). So it
may well be a different bug. I would rather not close 6523 but just add
a note in 4249 that the bugs may be related, unless someone knows for
sure that they are the same (rather than just appear related).
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/6523: bug with pointers to template functions
@ 2002-05-27 7:56 Reichelt
0 siblings, 0 replies; 4+ messages in thread
From: Reichelt @ 2002-05-27 7:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/6523; it has been noted by GNATS.
From: Reichelt <reichelt@igpm.rwth-aachen.de>
To: gcc-gnats@gcc.gnu.org, oliver.schoenborn@utoronto.ca, gcc-bugs@gcc.gnu.org,
nobody@gcc.gnu.org
Cc:
Subject: Re: c++/6523: bug with pointers to template functions
Date: Mon, 27 May 2002 16:49:49 +0200
Hi,
the example can be reduced to the one in PR 4249.
Therefore, the PR can probably be closed.
Greetings,
Volker Reichelt
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6523
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4249
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: c++/6523: bug with pointers to template functions
@ 2002-05-15 6:43 lerdsuwa
0 siblings, 0 replies; 4+ messages in thread
From: lerdsuwa @ 2002-05-15 6:43 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, oliver.schoenborn
Synopsis: bug with pointers to template functions
State-Changed-From-To: open->analyzed
State-Changed-By: lerdsuwa
State-Changed-When: Wed May 15 06:43:19 2002
State-Changed-Why:
Confirmed. Still present in 3.1 branch and main trunk.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6523
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-05-28 2:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-30 14:46 c++/6523: bug with pointers to template functions Oliver Schoenborn
2002-05-15 6:43 lerdsuwa
2002-05-27 7:56 Reichelt
2002-05-27 20:55 Oliver Schoenborn
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).