License: Creative Commons Attribution 3.0 Unported license (CC BY 3.0)
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2016.8
URN: urn:nbn:de:0030-drops-61024
URL: http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2016/6102/
Eyolfson, Jon ;
Lam, Patrick
C++ const and Immutability: An Empirical Study of Writes-Through-const
Abstract
The ability to specify immutability in a programming language is a
powerful tool for developers, enabling them to better understand and
more safely transform their code without fearing unintended changes to program state. The C++ programming language allows developers to
specify a form of immutability using the const keyword. In this work, we characterize the meaning of the C++ const qualifier and present the ConstSanitizer tool, which dynamically verifies a stricter form of immutability than that defined in C++: it identifies const uses that are either not consistent with transitive immutability, that write to mutable fields, or that write to formerly-const objects whose const-ness has been cast away.
We evaluate a set of 7 C++ benchmark programs to find writes-through-const, establish root causes for how they fail to respect our stricter definition of immutability, and assign attributes
to each write (namely: synchronized, not visible, buffer/cache,
delayed initialization, and incorrect). ConstSanitizer finds 17
archetypes for writes in these programs which do not respect our
version of immutability. Over half of these seem unnecessary to us.
Our classification and observations of behaviour in practice
contribute to the understanding of a widely-used C++ language feature.
BibTeX - Entry
@InProceedings{eyolfson_et_al:LIPIcs:2016:6102,
author = {Jon Eyolfson and Patrick Lam},
title = {{C++ const and Immutability: An Empirical Study of Writes-Through-const}},
booktitle = {30th European Conference on Object-Oriented Programming (ECOOP 2016)},
pages = {8:1--8:25},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-014-9},
ISSN = {1868-8969},
year = {2016},
volume = {56},
editor = {Shriram Krishnamurthi and Benjamin S. Lerner},
publisher = {Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik},
address = {Dagstuhl, Germany},
URL = {http://drops.dagstuhl.de/opus/volltexte/2016/6102},
URN = {urn:nbn:de:0030-drops-61024},
doi = {10.4230/LIPIcs.ECOOP.2016.8},
annote = {Keywords: empirical study, dynamic analysis, immutability}
}
Keywords: |
|
empirical study, dynamic analysis, immutability |
Collection: |
|
30th European Conference on Object-Oriented Programming (ECOOP 2016) |
Issue Date: |
|
2016 |
Date of publication: |
|
18.07.2016 |