In my code, I am using an array xyz of 10 objects. When I am trying to access an element of the array using an unsigned int index like this: xyz[level], I get 'Buffer overrun' warning. Logically, I am pretty sure that level won't exceed 10. How to avoid this warning?
1
votes
Can you post the code where you're getting the warning?
- Dean Harding
Not sure. This is a pretty big code base I am working on. I am trying to reproduce it with a small example. Let me post it when I succeed. Thanks!
- bdhar
2 Answers
9
votes
2
votes
Are you really sure? I never got this warning until now. So, double check.
Anyway, you can use the
#pragma warning( disable: 6386 )
preprocessor directive. I usually push and pop this to the "pragma stack"
#pragma warning( push )
#pragma warning( disable : 6386 )
// Some code
#pragma warning( pop )
as advised here.