编码指南和不可判定性
Coding Guidelines and Undecidability
摘要:
C和C++程序设计语言广泛用于关键系统中的软件实现。它们是复杂的语言,具有微妙的特性和特殊性,甚至可能使更专业的程序员感到困惑。因此,在大多数功能安全标准中出现的语言子集的一般规定,相当于只使用“更安全”的语言子集,特别适用于它们。编码指南是表达语言子集的首选方式。有些指导原则是根据程序设计语言及其实现制定的:在这种情况下,它们可以自动检查。然而,由于计算的基本限制,一些准则是不可判定的,也就是说,它们基于当前和未来算法无法在所有情况下捕获的程序属性。最成熟和广泛的编码标准,MISRA的,明确地标记准则与不可判定或可判定。事实证明,这些信息不是次要的,必须考虑到充分理解指南的要求。事实上,不可判定性是困扰编码标准和相关检查工具的许多用户的常见原因。在本文中,我们回顾了可判定性和不可判定性的概念,任何C/C++程序员都可以理解。本文系统研究了MISRA C:2012指南中所有的不可判定性,讨论了不可判定性的原因及其后果。我们特别注意不可判定的准则,这些准则具有可判定的近似值,其执行不会过度约束源代码。我们还讨论了一些编码准则,即使不是不可能,也很难证明它们的合规性,甚至超出了可判定性的问题。
英文摘要:
The C and C++ programming languages are widely used for the implementation of software in critical systems. They are complex languages with subtle features and peculiarities that might baffle even the more expert programmers. Hence, the general prescription of language subsetting, which occurs in most functional safety standards and amounts to only using a "safer" subset of the language, is particularly applicable to them. Coding guidelines are the preferred way of expressing language subsets. Some guidelines are formulated in terms of the programming language and its implementation only: in this case they are amenable to automatic checking. However, due to fundamental limitations of computing, some guidelines are undecidable, that is, they are based on program properties that no current and future algorithm can capture in all cases. The most mature and widespread coding standards, the MISRA ones, explicitly tag guidelines with undecidable or decidable. It turns out that this information is not of secondary nature and must be taken into account for a full understanding of what the guideline is asking for. As a matter of fact, undecidability is a common source of confusion affecting many users of coding standards and of the associated checking tools. In this paper, we recall the notions of decidability and undecidability in terms that are understandable to any C/C++ programmer. The paper includes a systematic study of all the undecidable MISRA C:2012 guidelines, discussing the reasons for the undecidability and its consequences. We pay particular attention to undecidable guidelines that have decidable approximations whose enforcement would not overly constrain the source code. We also discuss some coding guidelines for which compliance is hard, if not impossible, to prove, even beyond the issue of decidability.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。