C++ const and Immutability: An Empirical Study of Writes-Through-const.

ECOOP(2016)

引用 23|浏览64
暂无评分
摘要
The ability to specify immutability in a programming language is apowerful tool for developers, enabling them to better understand andmore safely transform their code without fearing unintended changes to program state. The C++ programming language allows developers tospecify 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 attributesto each write (namely: synchronized, not visible, buffer/cache,delayed initialization, and incorrect). ConstSanitizer finds 17archetypes for writes in these programs which do not respect ourversion of immutability. Over half of these seem unnecessary to us.Our classification and observations of behaviour in practicecontribute to the understanding of a widely-used C++ language feature.
更多
查看译文
AI 理解论文
溯源树
样例
生成溯源树,研究论文发展脉络
Chat Paper
正在生成论文摘要