Possible template parser bug

H

Hendrik Schober

Hi,

this is a cut down version of some some template
meta stuff that I have:

///////////////////////////////////////////////////////
template< typename TL, typename TR >
struct Dummy1 {};

template< typename TL, typename TR
, template<typename,typename> class TDummy >
struct Operation;

template< typename TL1, typename TL2
, typename TR
, template<typename,typename> class TDummy >
struct Operation< TDummy<TL1,TL2>
, TR
, TDummy > {
typedef TDummy<TL1,TL1> Result;
};

template< typename TL1, typename TL2
, typename TR1, typename TR2
, template<typename,typename> class TDummy >
struct Operation< TDummy<TL1,TL2>
, TDummy<TR1,TR2>
, TDummy > {
typedef TDummy<TL1,TL1> Result;
};

typedef Dummy1<int ,float > T1A;
typedef Dummy1<long,double> T1B;

typedef Operation< T1A , T1B , Dummy1 >::Result T3;
///////////////////////////////////////////////////////

Comeau and CodeWarrior 9 agree with me that this code
is fine. VC7.1, however, barks at me:

test.cpp(29) : error C2752: 'Operation<TL,TR,TDummy>' :
more than one partial specialization matches the template argument list
test.cpp(24): could be 'Operation< TDummy<TL1,TL2>, TDummy<TR1,TR2>, TDummy >'
test.cpp(15): or 'Operation< TDummy<TL1,TL2>, TR, TDummy >'

I think this is a bug in VC7.1.
I cannot currently test this with VC8.

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett
 
C

Carl Daniel [VC++ MVP]

Hendrik said:
I think this is a bug in VC7.1.

I think you're right, but I haven't spent the time to really argue that
case.
I cannot currently test this with VC8.

VC8 (Beta 1 Refresh) produces the same error messages as 7.1.

-cd
 
H

Hendrik Schober

Carl Daniel said:
I think you're right, but I haven't spent the time to really argue that
case.


VC8 (Beta 1 Refresh) produces the same error messages as 7.1.

Interestingly, GCC agrees with VC here. (Which
is rather rare IME. <g> )
Nevertheless, due to experience I tend to trust
Comeau and CW over VC and GCC.


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett
 
T

Tom Widmer

Hendrik said:
Interestingly, GCC agrees with VC here. (Which
is rather rare IME. <g> )
Nevertheless, due to experience I tend to trust
Comeau and CW over VC and GCC.

Yes, Comeau and CW are correct. The second partial specialization is
clearly more specialized than the first (you can synthesize types from
the first that the second can't match but not vice versa).

Tom
 
H

Hendrik Schober

Tom Widmer said:
[...]
Yes, Comeau and CW are correct. The second partial specialization is
clearly more specialized than the first (you can synthesize types from
the first that the second can't match but not vice versa).

Thanks, Tom. That's what I figured, although
I couldn't word it as good as you. :)
I should report this then.


Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top