[C++] Failure to deduce template arguments on class template / method name collision - by CodingCat

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


5
0
Sign in
to vote
ID 682686 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 8/2/2011 10:22:36 AM
Access Restriction Public

Description

The VC++ 2010 compiler fails to properly deduce the template arguments of a class template whose name collides with the name of another member function that resides in the same class as the member function whose parameter types are to be deduced.
Sign in to post a comment.
Posted by CodingCat on 8/16/2011 at 3:40 PM
Alright, I had expected the 'class' in 'class base<S>' to exclude all non-type-or-template names from name lookup as indicated by '3.4.4 Elaborated type specifiers' in my copy of '03s draft. However, on closer inspection, it seems that this behavior is not explicitly specified for template identifiers as I would have expected it to be as a logical continuation of the non-template name lookup rules.

Apparently, the language specification is missing the notion of elaborated template specifiers in name lookup, although the behavior discussed in this bug report seems rather unreasonable, and is quite inconvenient considering the sporadic necessity to be able to distinguish between type-or-template and non-type-or-template identifiers.
Posted by Microsoft on 8/16/2011 at 1:44 PM
Hi: the error message is not the best but in this case the compiler is correct. During name-lookup for 'base' the compiler is finding the member function 'base' instead of the base-class 'base' (which is the correct result according to the C++ name-lookup rules) and hence it fails to compile the code. The EDG compiler agrees with us (and gives better error messages):

"t250816.cpp", line 11: error: function "deduce::base" is not a template
        explicit deduce(class base<S> &)
                             ^
         detected during instantiation of "deduce::deduce" based on template
                    argument <float> at line 32

"t250816.cpp", line 16: error: function "deduce::base" is not a template
        explicit deduce(class base<S>&, class base<S>&)
                             ^
         detected during instantiation of "deduce::deduce" based on template
                    argument <float> at line 33

"t250816.cpp", line 16: error: function "deduce::base" is not a template
        explicit deduce(class base<S>&, class base<S>&)
                                             ^
         detected during instantiation of "deduce::deduce" based on template
                    argument <float> at line 33

3 errors detected in the compilation of "t250816.cpp".


Jonathan Caves
Visual C++ Compiler Team
Posted by MS-Moderator08 [Feedback Moderator] on 8/2/2011 at 9:52 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/2/2011 at 10:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)