none
Variable not accessible in watch window

    Question

  • Hello,

    If the type of a variable has the same name as the function it occurs in, it is not visible in the watch window, like this:

    struct data
    {
      int buff[10];
      int sum;
    };
    
    int data(int offset)
    {
      int i = 0, sum = 0;
      struct data DAT;
    
      DAT.sum = 0;
      while(i < 10)
      {
        DAT.buff[i] = i + offset;
        DAT.sum += DAT.buff[i];
        i++;
      }
      return (sum = DAT.sum);
    }  /* Break point here */
    
    
    

    Version of Visual Studio is:

    Microsoft Visual Studio Professional 2013

    Version 12.0.40629.00 Update 5

    Is this a known bug ?

    Regards,

    Even

    Friday, December 02, 2016 8:57 AM

Answers

All replies

  • >If the type of a variable has the same name as the function it occurs in, it is not visible in the watch window

    This still the same in VS2017 RC.

    It's not accessible in any of the debugger tools, not just the watch
    window.

    Interestingly, in a C++/CLI project, it works, so it only seems to be
    a problem with the native tools.

    I suggest that you report it on the MS Connect site against the
    highest version of VS on there. I would suggest using the reporting
    tool in VS2017 if you have that - except its bug reporting is losing
    all my reports!

    If you post a link to your connect report back here, I'll
    vote/validate it.

    Dave

    Friday, December 02, 2016 9:44 AM
  • I should have mentioned, the MS Connect site is:
    https://connect.microsoft.com/VisualStudio

    Dave

    Friday, December 02, 2016 10:49 AM
  • Hi EvenAn,

    Do you declare both the data Struct  and data method in the same class?

    As far as I know, we could not declare  the same definitions in one class. It will give us a error message about "The type 'Program' already contains a definition for 'data'" in error message, which will lead to the program could be not compile.

    Please tell us the detailed steps about how to use your sample code to help us reproduce your problem. After reproducing this issue, I will help you submit this issue to Visual Studio Connect. Thanks.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 05, 2016 6:51 AM
    Moderator
  • Thank you for checking this out,

    Reported as:

    https://connect.microsoft.com/VisualStudio/feedback/details/3114307

    Even

    Monday, December 05, 2016 11:19 AM
  • Reported as:
    https://connect.microsoft.com/VisualStudio/feedback/details/3114307

    OK, I've validated/voted it and added a comment.

    It'd be best if you create a simple console project and step-by-step
    instructions on reproducing the problem - it makes someone's life
    easier at MS's end and ensures that your report isn't discarded before
    the first hurdle.

    Dave

    Monday, December 05, 2016 12:11 PM
  • Hi EvenAn,

    Thanks for sharing your feedback link here. Please mark your feedback reply as answer which could let other communities who has the same problem to vote and add comments.

    And please wait for the response from Visual Studio report team. They will treat this issue seriously。

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 06, 2016 1:36 AM
    Moderator