------- Additional Comments From mark at codesourcery dot com  2005-05-29 17:18 
-------
Subject: Re:  [3.4 regression] local classes as template argument

Geoffrey Keating wrote:
> Hi Mark,
> 
> Consider this code:
> 
> struct Attribute { };
> template <class T> void fun (const Attribute &attr, const T &value);
> extern void fun (int attr, int value);
> enum { anon = 666 };
> 
> void test(int foo)
> { fun (foo, anon); }
> 
> I believe this is valid C++.  Template argument deduction will fail  
> when it compares the type of the *first* parameter of fun(), since no  
> value of T can be found that will make the first parameter match.

As you've discovered, we don't perform template argument deduction on 
arguments that do not involve template types.  I agree that there's 
nothing in the standard to support that behavior.  However, there are a 
lot of DRs in this area, and we should check the behavior of other 
compilers before making any changes here.  Those checks should be done 
without using anonymous enums, since there's additional controversy 
around that particular issue; instead, some way to isolate what set of 
template functions can be deduced is required.

I don't remember the origin of the comment in the code that refers to 
infinite recursion.  I don't think adding DEDUCE_CALL to the condition 
makes sense, though; either we should always do the comparsion, or only 
when DEDUCE_EXACT.  Furthermore, your change is not correct, in that 
deduction permits non-exact matches for calls; see [temp.deduct.call].



-- 


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

Reply via email to