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.
翻译:C和C++ 编程语言被广泛用于在关键系统中实施软件。它们是复杂的语言,具有微妙的特征和特殊性,可能会令更专业的编程者感到困惑。因此,大多数功能性安全标准中出现的语言子设置的一般处方,特别适用于这些语言。编码指南是表达语言子集的首选方式。有些指南是在编程语言及其实施方面制定的:在这种情况下,它们可以自动检查。但是,由于计算存在根本性的局限性,有些指南是无法确定的,也就是说,它们基于程序属性,而目前和未来的算法无法在所有情况下都能够捕捉到。最成熟和广泛的编码标准,只是使用“安全”的该语言子集。编码指南是表达语言子集的首选方法。有些指南是用程序语言表达的次选方法。有些指南需要完全理解。一个事实,不可确定性的来源是模糊性,有些代码是无法识别的,有些用户无法进行编程的代码是无法确定性,因此,一个不可理解性的文件定义是,一个不可理解性概念。我们回顾的是,一个无法理解的Cdrifildal dal durity 。