1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Charvar

From cppcheck

Jump to: navigation, search

Dangerous usage of char variables

Using char variables is not always safe.

char s8 = 0xff;

char ch1 = str[s8];	// str[s8] = str[0xffffffff]
int result1 = 1 | s8;	// 1 | s8 => 1 | 0xffffffff

c++check detects these problems.

There will be false positives if either:

  • It's the intended behaviour
  • You know the variable will never have dangerous values

Because of the false positives, this check is in the "--all" checks.

Personal tools