[issue10044] small int optimization

Mark Dickinson report at bugs.python.org
Thu Oct 7 23:00:38 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

> Technically arbitrary relational comparisons of pointers are undefined,
> but in practice Antoine's assumptions here are very modest.

I disagree:  there's a very real practical danger here.  Namely, optimizing compilers are free to assume that code doesn't involve any undefined behaviour and optimize accordingly.  gcc for one is known to make extensive use of this freedom.  I wouldn't be at all surprised to find some current or future version of gcc optimizing an (p >= start_of_array) check to 'always true', on the basis that it *will* always be true in legal code.

Please don't introduce undefined behaviour here---it's asking for trouble.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10044>
_______________________________________


More information about the Python-bugs-list mailing list