Detecting uninitialized variables in C++ with the clang static analyzer

2Citations
Citations of this article
5Readers
Mendeley users who have this article in their library.

Abstract

Uninitialized variables have been a source of errors since the beginning of software engineering. Some programming languages (e.g. Java and Python) will automatically zero-initialize such variables, but others, like C and C++, leave their state undefined. While laying aside initialization in C and C++ might be a performance advantage if an initial value cannot be supplied, working with variables is an undefined behaviour, and is a common source of instabilities and crashes. To avoid such errors, whenever meaningful initialization is possible, it should be applied. Tools for detecting these errors run time have existed for decades, but those require the problematic code to be executed. Since in many cases, the number of possible execution paths is combinatoric, static analysis techniques emerged as an alternative to achieve greater code coverage. In this paper, we overview the technique for detecting uninitialized C++ variables using the Clang Static Analyzer, and describe various heuristics to guess whether a specific variable was left in an undefined state intentionally. We implemented and published a prototype tool based on our idea and successfully tested it on large open-source projects. This so-called “checker” has been a part of LLVM/Clang releases since 9.0.0 under the name optin.cplusplus.UninitializedObject.

Cite

CITATION STYLE

APA

Umann, K., & Porkoláb, Z. (2020). Detecting uninitialized variables in C++ with the clang static analyzer. Acta Cybernetica, 25(4). https://doi.org/10.14232/actacyb.282900

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free