c++/4633: g++ 3.0.1 bogus error on nested partial specialization

sebor@roguewave.com sebor@roguewave.com
Sat Oct 20 14:46:00 GMT 2001


>Number:         4633
>Category:       c++
>Synopsis:       g++ 3.0.1 bogus error on nested partial specialization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 20 14:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     sebor@roguewave.com
>Release:        3.0.1
>Organization:
>Environment:
i386-pc-solaris2.8
>Description:
The code snippet below fails to compile with g++ 3.0.1,
giving an obviously bogus error.

Regards
Martin

>How-To-Repeat:
$ cat t.cpp ; g++ -v ; g++ t.cpp
struct N;

template <class T, class U>
struct L { };

template <class T, template <class, class> class>
struct S;

template <class T, template <class, class> class P>
struct S<L<T, N>, P> { typedef L<T, N> Result; };

template <class T, class U, template <class, class> class P>
struct S<L<T, U>, P>
{
    template <class> struct M;
    template <class V> struct M<L<V, N> > { typedef V Y; };

    template <class V, class W>
    struct M<L<V, W> > { typedef typename P<V, typename M<W>::Y>::Y Y; };

    template <class, class> struct R;
    template <class V> struct R<L<V, N>, V> { typedef N Y; };
    template <class V, class W> struct R<L<V, W>, V> { typedef W Y; };

    template <class V, class W, class X>
    struct R<L<V, W>, X> { typedef L<V, typename R<W, X>::Y> Y; };

    typedef typename M<L<T, U> >::Y X;
    typedef L<X, typename S<typename R<L<T, U>, X>::Y, P>::Result> Result;
};

Reading specs from /usr/local/gcc-3.0.1/lib/gcc-lib/i386-pc-solaris2.8/3.0.1/specs
Configured with: ../gcc-3.0.1/configure --prefix=/usr/local/gcc-3.0.1 --enable-languages=c,c++ --enable-threads
Thread model: posix
gcc version 3.0.1
t.cpp:28: declaration of `typedef typename S<L<T, U>, P>::M<L<T, U> >::Y S<L<T, 
   U>, P>::X'
t.cpp:25: changes meaning of `X' from `class X'
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list