With hind sight, it would appear that as many of these difficulties
seem rooted in the historical implicit declaration/conversions of
variables/parameters to signed int which has correspondingly tended
to be implemented as having wrapping semantics regardless of overflow
being undefined; and as typically the greatest interest in optimization
tends to be focusing on loops which have historically utilized default
int indexes although most typically never intending to rely on negative
or modular wrapping semantics; I wonder if rather than attempting to
argue further about whether ints should wrap or not, both signed and
unsigned should simply be assumed to wrap by default; and add a flag to
enable the specific optimization of only loop index variables such that
either or both signed and unsigned indexes are assumed to never overflow
or modulo wrap, and enable the explicit assertion of explicit value ranges
within code by adding a flag to interpret or ignore assert expressions
as value range assertions as previously proposed by others on a few past
occasions.

Thereby most code will simply work based on historical assumptions, and
loops may be explicitly enabled to be further optimized in bulk by
assuming non-wrapping index semantics, and/or explicit assertions may
be added to more finely control the assumptions otherwise desired with
knowledge of the program.



Reply via email to