Microsoft KB Archive/314280

= BUG: Debugger Cannot Distinguish Between Template Functions and Overloaded Functions with Same Names =

Article ID: 314280

Article Last Modified on 5/28/2003

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-



This article was previously published under Q314280



SYMPTOMS
If a template function has the same name and scope as a non-template (overloaded) function, the Microsoft Visual Studio .NET debugger cannot distinguish between the functions when the debugger sets a breakpoint.



RESOLUTION
If you can choose a specialized template, do not use a non-template function overload. For example, use the definition in the following code: template < > double templatefunc(double var){ ... }



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Open Visual Studio .NET, and then create a Managed C++ Empty Project in the Microsoft Visual Studio .NET integrated development environment (IDE).  Add a Visual C++ source file to the project, and then add the following code to the source file: template Type templatefunc(Type var) {    Type xx = var; return var; }

double templatefunc(double var) {    double dblVar = var / 10; return dblVar; }

void main {      templatefunc(1.2); templatefunc('a'); templatefunc(12); }                    Compile the project. Right-click the Type templatefunc(Type var) function, and then click New Breakpoint. In the New Breakpoint dialog box, click OK.</li> In the Choose Breakpoints dialog box, click All, and then click OK.</li> On the Debug menu, point to Windows, and then click Breakpoints.</li> In the Breakpoints dialog box, notice that two breakpoints appear (templatefunc and templatefunc(double)). Press F5.</li></ol>

When the Breakpoints dialog box appears, notice that two different breakpoints appear to have been hit at the same time. A plus sign (+) appears in front of the first templatefunc breakpoint. If you expand the plus sign (+), another templatefunc(double) breakpoint appears. Both functions show a hit count of 1.

The bottom templatefunc(double) breakpoint should not appear in the dialog box.

Keywords: kbbug kbnofix kbdebug kbnativeattributes KB314280

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.