Esc
Variable Initialization
Definition
Setting variables to a known value before use.
How it Works
Initializing variables upon declaration ensures that the variable has a known quantity before use.
Considerations
- Default behavior when declaring variables varies by language.
- This is particularly important in programming languages that do not initialize variables to a default value upon declaration. In these instances, the value that a variable will contain after declaration is indeterminate which can cause issues. In fact, that value could be different each time the program is ran.
- Note: This resource should not be considered a definitive or exhaustive coding guideline.
Artifact Relationships:
This defensive technique is related to specific artifacts. Click the artifact node for more information.
References
All
User Manual
External Knowledge Base
The following references were used to develop the Variable Initialization knowledge-base article.
(Note: the consideration of references does not imply specific functionality exists in an offering.)
Integer Initialization in C
Reference Type: User Manual Organization: GNU
CWE-457: Use of Uninitialized Variable
Reference Type: External Knowledge Base Organization: MITRE Author: MITRE