https://www.perforce.com/blog/kw/NASA-rules-for-developing-s....
https://www.perforce.com/blog/kw/NASA-rules-for-developing-s....
Here's a copy of the CERT C standard. The site you linked is incorrect. If you google GOTO error handling. Or any of the sort it will come up with it. You should'nt use goto in literally any other case besides this though, which is what I( assume they were referencing.
AUTOSAR C++14 guidelines don't allow goto in any case.
MISRA C++ 2008 does have a couple of rules that allow this specific scenario.
MISRA C:2004, "goto shall not be used".
MISRA C:2012, it was weakened to "goto should not be used".
Open to see examples of (good) C code that doesn't use it though.
if(something_bad)
{
err = BADTHING1;
goto oops;
}
// more stuff
return 0;
oops:
return err;
I'll add1. keep code that performs calculations separate from code that performs side effects. In fact isolate the latter as much as possible.
2. Avoid spooky action at a distance. Code should relentlessly work towards a clear goal.