[Bug c++/13808] New: conversion operator template with template as parameter fails parsing

gianni at mariani dot ws gcc-bugzilla@gcc.gnu.org
Thu Jan 22 03:40:00 GMT 2004


The code below compiles fine under Comeau and VC++7.1.

gcc 3.3.2 gives the following diagnostic:

t2x.cpp:14: error: parse error before `<' token
t2x.cpp:14: error: syntax error before `<' token
t2x.cpp:19: error: parse error before `}' token
t2x.cpp: In function `int main()':
t2x.cpp:33: error: conversion from `X' to non-scalar type `D<char, char>'
   requested
make: *** [t2x] Error 1

The "struct C" commented allows this to compile and function as expected which
indicates that there most likely is a parsing error (expecting a typename but
have a template instead).  Using the "typename" keyword does not correct the
problem.

struct X
{
//  struct C; //uncomment to make this work.

    template<typename T,  typename A, template<typename,typename> class C>
    C<T, A> Func()
    {
        return C<T, A>();
    }

    template<typename T,  typename A, template<typename,typename> class C >
    operator C<T, A> ()
    {
        return C<T, A>();
    }

};

template<typename dpt, typename dpa>
class D
{
};

int main()
{
    X   x;

    x.Func<char, char, D>();

    D<char,char>    d = x;
}


Credit for finding this problem goes to: Leor Zolman
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=58nt00110jirtteaml6p5o45j6l19le1cl%404ax.com&rnum=9

-- 
           Summary: conversion operator template with template as parameter
                    fails parsing
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list