◐ Shell
clean mode source ↗

Message 301335 - Python tracker

> As suggested in http://bugs.python.org/issue31337#msg301229 it would be better to use
> abort() /* NOT REACHED */

Please don't use abort(), but add a new Py_UNREACHABLE() macro to allow to use a different code depending on the compiler/platform and compiler option (like release vs debug build).

> Can we use compiler-specific code like GCC's __builtin_unreachable()? This would help the optimizer.

That's a good example of better implementation for Py_UNREACHABLE().

The tricky part is to make compiler warnings quiet. For example, you cannot replace "abort(); return NULL;" with "abort()", because a function without return would emit a warning.

Maybe the default implementation of the macro should be:

#define Py_UNREACHABLE(stmt) abort(); stmt

I don't know if it would work.