[issue38147] add macro for __builtin_unreachable

STINNER Victor report at bugs.python.org
Thu Sep 19 11:50:37 EDT 2019


STINNER Victor <vstinner at python.org> added the comment:

> Here's example: https://github.com/sir-sigurd/cpython/commit/c8699d0c614a18d558216ae7d432107147c95c28.

"_Py_ASSUME((size_t)size <= MAX_LONG_DIGITS);"

Typically, such code use assert() and is removed for release build.

assert() is more for contract base programming: when the error "cannot" happen at runtime (it would be a programming error).

For other cases, I prefer to always emit code to handle the error (the error can happen, for example, the function must check inputs), even in release build.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38147>
_______________________________________


More information about the Python-bugs-list mailing list