Microsoft KB Archive/123160

= FIX: Conditional Breakpoint Doesn't Stop in Recursive Function =

Article ID: 123160

Article Last Modified on 12/9/2003

-

APPLIES TO

 The Integrated Debugger, when used with:  Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 2.0 Professional Edition 

-

<div class="notice_section">

This article was previously published under Q123160

<div class="symptoms_section">

SYMPTOMS
Using "Break when Expression is True" in a recursive function in the Visual C++ integrated debugger may fail to stop program execution even if the expression becomes true.

<div class="resolution_section">

RESOLUTION
Instead of using "Break when Expression is True," use "Break at Location if Expression is True" to work around the problem.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was not reproducible in Microsoft Visual C++, 32-bit Edition, version 4.0.

<div class="moreinformation_section">

MORE INFORMATION
To demonstrate the problem, build the sample code below for debug mode and do the following:


 * 1) Choose Breakpoints... from the Debug menu.
 * 2) In the Breakpoints dialog, select "Break when Expression is True" for the Type field.
 * 3) In the Expression field, type {function1}(i==2) to specify the expression.
 * 4) Add the above breakpoint to the "Breakpoints:" list.
 * 5) Start the debugger. You will notice that the debugger terminates the debug session without breaking, even though i was equal to 2 at one point.

Sample Code
/* Compile options needed: /Zi /Od


 * 1) include <stdio.h>

int function1( int i, int j ) { if ( i>0 ) {   return function1( i-1, j+1 ); } else {   return j;  } }

void main(void) { int i;

printf( "Before Recursive Call.\n" ); i = function1( 10, 0 ); printf( "Back from Recursive Call.\n" ); }

Additional query words: 1.00 1.50 2.00 2.10

Keywords: kbbug kbfix kbide kbdebug KB123160

-

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

© Microsoft Corporation. All rights reserved.