Mysterious values in IDE when debugging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alfonzo Morra

    #1

    Mysterious values in IDE when debugging

    Hi,

    I recently started using VC7.1 (upgraded from VC6). I've noticed that
    when stepping through code, some of the values of my variables make no
    sese at all. For instance, I had some code like this:

    int i = 1, j =1 ;
    for ( MyClass::Result Type::const_ite rator ResultIt =
    ShowAll.getResu lts().begin(); ResultIt != ShowAll.getResu lts().end();
    ++ResultIt, i++ ) {
    .......
    cout << "Value of i is : " << i << endl ;


    When I hovered my mouse ptr over the variable i, in the 'for'
    expression, I got a nonsensical number: 2012749653 - however the value
    printed on the console was correct.

    When I "dragged" the variable named i to the watch window, I got the ff
    error message: "i CXX0069: Error: variable needs stack frame", and this
    was still within the for loop, so the i variable must have still been on
    the stack - any body care to shed some light on wtf is going on?

    Thanks

  • David Lowndes

    #2
    Re: Mysterious values in IDE when debugging

    >I recently started using VC7.1 (upgraded from VC6). I've noticed that[color=blue]
    >when stepping through code, some of the values of my variables make no
    >sese at all. For instance, I had some code like this:
    >...
    >When I hovered my mouse ptr over the variable i, in the 'for'
    >expression, I got a nonsensical number: 2012749653 - however the value
    >printed on the console was correct.[/color]

    Alfonzo,

    Are you debugging a release optimised build rather than the debug
    non-optimised build? The results you mentioned are typical when
    debugging optimised builds.

    Dave

    Comment

    • Alfonso Morra

      #3
      Re: Mysterious values in IDE when debugging



      David Lowndes wrote:
      [color=blue][color=green]
      >>I recently started using VC7.1 (upgraded from VC6). I've noticed that
      >>when stepping through code, some of the values of my variables make no
      >>sese at all. For instance, I had some code like this:
      >>...
      >>When I hovered my mouse ptr over the variable i, in the 'for'
      >>expression, I got a nonsensical number: 2012749653 - however the value
      >>printed on the console was correct.[/color]
      >
      >
      > Alfonzo,
      >
      > Are you debugging a release optimised build rather than the debug
      > non-optimised build? The results you mentioned are typical when
      > debugging optimised builds.
      >
      > Dave[/color]

      Hi Dave,

      Thanks for reply - but no, this was my own code that I was running in
      debug mode.

      Comment

      • David Lowndes

        #4
        Re: Mysterious values in IDE when debugging

        >> Are you debugging a release optimised build rather than the debug[color=blue][color=green]
        >> non-optimised build? The results you mentioned are typical when
        >> debugging optimised builds.
        >>[/color]
        >Thanks for reply - but no, this was my own code that I was running in
        >debug mode.[/color]

        Have you checked the compiler optimisation setting is set to /Od for
        the source file(s)/project in question?

        Dave
        --
        MVP VC++ FAQ: http://www.mvps.org/vcfaq

        Comment

        Working...