public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8876: ICE in resolve_offset_ref, at cp/init.c:1824
@ 2002-12-09 19:32 bangerth
0 siblings, 0 replies; only message in thread
From: bangerth @ 2002-12-09 19:32 UTC (permalink / raw)
To: benoitsevigny, gcc-bugs, gcc-prs, nobody
Old Synopsis: wrong template instantiation
New Synopsis: ICE in resolve_offset_ref, at cp/init.c:1824
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Mon Dec 9 19:32:52 2002
State-Changed-Why:
Confirmed. A shorter and easier to understand testcase is
this one:
-------------------------------------------
#include <stdlib.h>
template<int f> struct Outer {
template <int> struct Inner {
static void func() { abort (); }
};
};
template<> struct Outer<3> {
template <int> struct Inner {
static void func() { }
};
};
template <int N> struct C {
template <int M> static void foo() {
Outer<N+M>::Inner<0>::func();
}
};
int main(int argc, const char *argv[])
{
C<1>::foo<2> ();
return 0;
}
-------------------------------
In C<1>::foo<2>, we should call the inner class of the
specialization Outer<3>::Inner, but the call goes indeed
to the respective function of the Inner class of the
general template, hitting the abort() on execution. Note
that if I remove the unnecessary template parameter of
Inner, then everything is ok.
Further bugs one can trigger with this code: if
I remove the declaration of Outer<N>::Inner altogether
(after all, it should not be used, so I could do that),
then the compiler crashes altogether, supposedly while
looking up Inner in Outer<N>, where it should not look:
tmp/g> cat PR8876.cc
#include <stdlib.h>
template<int f> struct Outer {};
template<> struct Outer<3> {
template <int> struct Inner {
static void func() { }
};
};
template <int N> struct C {
template <int M> static void foo() {
Outer<N+M>::Inner<0>::func();
}
};
int main(int argc, const char *argv[])
{
C<1>::foo<2> ();
return 0;
}
tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/c++ PR8876.cc
PR8876.cc: In static member function `static void C<N>::foo() [with int M = 2,
int N = 1]':
PR8876.cc:19: instantiated from here
PR8876.cc:13: error: `::func' undeclared (first use here)
PR8876.cc:13: internal compiler error: in resolve_offset_ref, at cp/init.c:1824
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
Since ICEs are usually simpler to track than miscompilations,
I change the synopsis of this report to indicate the
second mode of failure. Whoever attempts to fix the
problem should look at the first testcase above, though.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8876
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-12-10 3:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-09 19:32 c++/8876: ICE in resolve_offset_ref, at cp/init.c:1824 bangerth
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).