analyzer icon indicating copy to clipboard operation
analyzer copied to clipboard

Warn when control flow reaches end of a `_Noreturn` function

Open michael-schwarz opened this issue 4 years ago • 1 comments

Since https://github.com/goblint/cil/pull/58, CIL supports the _Noreturn attribute.

As remarked by @sim642 on Slack, we should also do something with _Noreturn in Goblint and emit a warning when control flow does indeed reach the end of such a function (i.e. return node is not dead).

This probably also requires investigating which standard library functions terminate execution (e.g. exit(...) and friends).

michael-schwarz avatar Dec 16 '21 15:12 michael-schwarz

I think we already handle the usual suspects as non-returning: https://github.com/goblint/analyzer/blob/e81b1a147f420983583e680a57d8a6d8b071ca68/src/analyses/base.ml#L2188-L2205

Of course I guess a modern standard library header would also have them with _Noreturn (or equivalent). Actually it might be even worth having a sem option, whether to trust _Noreturn attributes (and make them all raise Deadcode just based on that). While doing that we could still warn about control flow reaching the end of the function within its implementation. This might avoid a cascade of _Noreturn warnings if we don't handle the innermost root cause.

sim642 avatar Dec 16 '21 16:12 sim642