[issue14656] Add a macro for unreachable code
Martin v. Löwis
report at bugs.python.org
Tue Apr 24 01:45:18 CEST 2012
Martin v. Löwis <martin at v.loewis.de> added the comment:
> Right, we currently avoid this problem by writing "assert(0)" for
> example in lookdict_split in dictobject.c. What I'm saying is that
> instead writing "assert(0)", we could use Py_UNREACHABLE.
I don't understand. The assert(0) is not there to silence any compiler
warnings, is it? Instead, ISTM that it is there to truly assert that
the code is not reached, which isn't actually obvious at all (IIUC, it's
not reached because there must be some empty slot eventually unless the
key is in there already).
Instead, ISTM that is actually the "return 0;" that should silence the
compiler warning about not having a return statement.
If that's all true, I fail to see what __builtin_unreachable would achieve:
we certainly have to preserve the return statement, for compilers not
supporting
such a declaration.
Wouldn't this actually have the undesirable effect of complaining about
the return statement when compiling with -Wunreachable-code?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14656>
_______________________________________
More information about the Python-bugs-list
mailing list