Hello¬†ūüźČ¬†UB¬†ūüź≤,
(resending.. again... with the right address.... darned email UB)

A recent MISRA discussion makes me wonder: why do we keep this UB around?

Shafik's paper has a short mention here: http://wg21.link/P1705#stmtreturn
 http://wg21.link/p2234 also talks about this.

The specific wording:
Flowing off the end of a constructor, a destructor, or a non-coroutine function with a cv void return type is equivalent to a return with no operand. Otherwise, flowing off the end of a function other than main or a coroutine results in undefined behavior.

We have [[noreturn]] to help express programmer intent around this, and we've got a proposal for std::unreachable (waiting for an update post LWG feedback) which IMO allows expressing intent which [[noreturn]] doesn't express.

Compilers diagnose when functions can't be proved to return, and I wouldn't work on a codebase without this diagnostic enabled as an error. Is there a valid reason to keep this UB around? I get that exceptions and longjmp and exit make this diagnostic conservative, but I'd rather have programmers express intent with [[noreturn]] and std::unreachable, which as far as I know compilers diagnose 100% accurately when used to express intent. It seems like we're keeping UB around when we have better tools ([[noreturn]] and std::unreachable) to opt-in to UB.

Thanks!

JF