This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/8876: ICE in resolve_offset_ref, at cp/init.c:1824


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]