The Impact of Compiler Warnings on Code Quality in C++ Projects
Paper in proceeding, 2024

Modern compilers often offer a variety of warning flags, which developers can enable to get feedback on code that, while syntactically correct, may be problematic. In the case of C++, one example of such 'correct but problematic' code is code that leads to undefined behavior (UB). The usage of compiler warnings has long been suspected as a way to decrease bugs and increase code quality. However, empirical evidence that supports this hypothesis is rare. In this study, we present evidence from a study of 127 open source C++ projects. We categorize their usage of compiler warnings into five groups based on which warning flags are being used, and analyse the relationship between compiler warnings and five quality metrics (bugs, critical issues, vulnerabilities, code smells, and technical debt) using Bayesian analysis. We conclude that, in general, compiler warnings indeed correlate with, and potentially cause, higher code quality, with the clearest impact being on the number of critical issues in a project. Using stricter warning flags expectantly correlates with higher code quality in our study objects. However, there are substantial differences between projects, which we attribute to the project's individual development culture. That is, while warnings matter, other factors such as quality culture, are likely to be even more important to source code quality.

Code Quality

Compiler Warnings

Bayesian Data Analysis

Author

Albin Johansson

Student at Chalmers

Carl Holmberg

Student at Chalmers

Francisco Gomes

Software Engineering 1

Philipp Leitner

Software Engineering 2

IEEE International Conference on Program Comprehension

26437147 (ISSN) 26437171 (eISSN)

270-279
979-840070586-1 (ISBN)

32nd IEEE/ACM International Conference on Program Comprehension, ICPC 2024
Lisbon, Portugal,

ImmeRSEd - Developer-Targeted Performance Engineering for Immersed Release and Software Engineers

Swedish Research Council (VR) (2018-04127), 2019-01-01 -- 2023-12-31.

Subject Categories

Software Engineering

Computer Science

DOI

10.1145/3643916.3644410

More information

Latest update

7/18/2024