Watch, Follow, &
Connect with Us

Please visit our new home

Public Report
Report From: Delphi-BCB/Debugger/Evaluator/C++    [ Add a report in this area ]  
Report #:  55856   Status: Open
Evaluate, Local Variables & Watch fail for STL iterators
Project:  C++Builder Build #:  11.0.2804.9245
Version:    11.1 Submitted By:   Leo Siefert
Report Type:  Basic functionality failure Date Reported:  12/11/2007 3:40:30 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   256763
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (3 Total Ratings)
4.33 out of 5
Total Votes: 61
In most real world cases it is impossible to examine the contents of an iterator using the Local Variables view, the Watch Window, a tooltip evaluation or an Evaluate/Modify window. This actually works sometimes, especially in small demo programs, but it routinely fails in real programs, at least with complex data types stored in the container.

This makes debugging extremely difficult as I must add debugging code to see the valuse of an iterator, then clean it up when I am done.

BTW - although the sample code is using a const iterator, the watch fails equally well for a non-const iterator. This can be shown by removing the const from the Changed function declaration and implementation and changing constTSqlFieldIt to TSqlFieldIt.
Steps to Reproduce:
Download and run the attached project
Confirm presence of breakpoint on line 24 of Unit1.cpp:  "return true;"
F9 to build and run in debugger
When run pauses at the breakpoint:

Expand this->Fields.MyFirst
Look at variable it in the Local Variables window (try to expand)

Exp: Contents of it match contents of this->Fields.MyFirst
Act: No contents shown for it, node cannot be expanede

Right-click on it in code and select Debug | Evaluate/Modify

Exp: View contents of iterator
Act: shows only { }

Look at *it in the Watch window

Exp: Contents of *it (note that the line before this in the program compiles and runs without error)
Act: *it
E2093 'operator*' not implemented in type 'std::_Vector_const_iterator<TSqlField, std::allocator<TSqlField> >' for arguments of the same type

Look at it->FileData in the watch window

Exp: see value of it->FileData "0*" (note that this expression is also already run on the previous line)
Act  it->FileData
E2288 Pointer to structure required on left side of -> or ->*

Hover mouse pointer over "it" in the code.

Exp: Tooltip evaluator will show the value
Act: Either no response at all or  "it | { }"


Server Response from: ETNACODE01