Get rid of reading invalid data warning

Taylor 21 Reputation points

I have this warning about reading invalid data, but the loop ensures that the range is valid. How can I suppress this warning? I know I can suppress all warnings of a certain ID but I just want to get rid of this one if that's possible in case this problem actually shows up later.![73829-screenshot-80.png][1] [1]: /api/attachments/73829-screenshot-80.png?platform=QnA

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,634 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
967 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dylan Zhu-MSFT 6,406 Reputation points

    Hi Taylor,

    You can add this code before this warning:

    #pragma warning(suppress: 6385)  
    if (players[playerNum].seed == 0){  

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**

1 additional answer

Sort by: Most helpful
  1. Viorel 114.7K Reputation points

    Probably we and the compiler cannot be sure that playerNum does not exceed the bounds of players.

    Maybe try another condition:

    . . .
    while( || iQ.answer < 1 || iQ.answer > players.size() )
    . . .

    (Assuming that players is a vector).