today we were discussing different spacecraft accidents caused by/related to software, discussed Arian-5 case, and I remembered a Soviet case, where there was a problem with decimal separator and Fortran compiler. Decimal separator in USSR was comma, but in Fortran code it should be the dot.

Also, Fortran compiler did not consider using comma instead of the dot as an error, but as different code. And my friend said - the same is possible to do in C++ - and sent me the illustration.

#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
if (1,2!=1.2)
{
cout << (1,2) << endl;
}
return 0;
}

if you run it, you’ll get

Hello World
2

(:

#safety #programming #mistakes #safe #c++ #code #example #programming-languages #programming_languages #arian #fortran #source

բնօրինակ սփիւռքում(եւ մեկնաբանութիւննե՞ր)

I took the 142 rules of the MISRA-C:2004 “Guidelines for the use of the C language in critical systems” and applied them to Oberon-07. I discovered that more than 70% of the rules are not required when programming in Oberon-07. They are either already enforced by the language or are not applicable.

Examples of MISRA rules that are not applicable to Oberon-07:

Rule 14.4: The goto statement shall not be used. (Oberon-07 does not have GOTO)

Rule 14.5: The continue statement shall not be used. (Oberon-07 does not have CONTINUE)

Examples of MISRA rules that are enforced by the design of Oberon-07:

Rule 14.7: A function shall have a single point of exit at the end of the function.

Rule 16.6: The number of arguments passed to a function shall match the number of parameters.

The remaining 30% of MISRA rules that also need to be checked when using Oberon-07 include:

Rule 2.4 (advisory): Sections of code should not be “commented out”.

Rule 20.4: Dynamic heap memory allocation shall not be used.

source

#programming #oberon-2 #oberon-07 #oberon #misra #safety #safe #guidelenies

բնօրինակ սփիւռքում(եւ մեկնաբանութիւննե՞ր)