Bug 13808 - conversion operator template with template as parameter fails parsing
Summary: conversion operator template with template as parameter fails parsing
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-01-22 03:40 UTC by gianni
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gianni 2004-01-22 03:40:04 UTC
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
Comment 1 Andrew Pinski 2004-01-22 06:25:42 UTC
Fixed for 3.4 by the new parser.