Typedef mismatch
Mismatch between typedef statements
Description
This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
This defect occurs when typedef statements lead to conflicting underlying
types for one of these data types:
size_tssize_twchar_tptrdiff_t
Risk
If you change the underlying type of size_t, ssize_t, wchar_t,
or ptrdiff_t, you have inconsistent definitions
of the same type. Compilation units with different include paths can
potentially use different-sized types causing conflicts in your program.
For example, say that you define a function in one compilation
unit that redefines size_t as unsigned long. But
in another compilation unit that uses the size_t definition
from <stddef.h>, you use the same function
as an extern declaration. Your program will encounter
a mismatch between the function declaration and function definition.
Fix
Use consistent type definitions. For example:
Remove custom type definitions for these fundamental types. Only use system definitions.
Use the same size for all compilation units. Move your
typedefto a shared header file.
Examples
Result Information
| Group: Programming |
| Language: C | C++ |
| Default: On |
Command-Line Syntax: TYPEDEF_MISMATCH |
| Impact: High |
Version History
Introduced in R2016b
See Also
Declaration mismatch | Find defects (-checkers)
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)