------- Comment #9 from bangerth at dealii dot org  2006-11-09 05:33 -------
PR29767 made me try whether we can achieve the same wrong effect for
template type parameters, and indeed we can:
--------------------
template <typename T> struct outer { 
    template <typename T2, typename U> 
    struct inner { 
        static int f() { return inner<T,int>::N; }; 
    }; 

    template <typename U> 
    struct inner<T,U> { 
        static const int N = 1; 
    }; 
}; 

int i = outer<int>::inner<double,int>::f(); 
------------------
This compiles with icc, but doesn't with gcc:
g/x> /home/bangerth/bin/gcc-4.2-pre/bin/c++ -c x.cc
x.cc: In static member function &#8216;static int outer<T>::inner<T2, U>::f()
[with T2 = double, U = int, T = int]&#8217;:
x.cc:13:   instantiated from here
x.cc:4: error: &#8216;N&#8217; is not a member of &#8216;outer<int>::inner<int,
int>&#8217;

As PR29767 shows, this can actually lead to wrong code.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|non type boolean template   |Specialization of inner
                   |argument partial            |template using outer
                   |specialization to argument  |template argument doesn't
                   |in parent never matches     |work


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14032

Reply via email to