[Bug tree-optimization/27039] [4.1/4.2 Regression] Unable to determine # of iterations for a simple loop
rguenth at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu May 4 14:21:00 GMT 2006
------- Comment #8 from rguenth at gcc dot gnu dot org 2006-05-04 14:21 -------
Wording of 6.5.6/8 and /9 suggests that array objects larger than the maximum
value that fits in ptrdiff_t (which needs to be signed) invoke undefined
behavior,
not last because of "the expression ((Q)+1)-(P) has the same value as
((Q)-(P))+1 and as -((P)-((Q)+1))" and "The size of the result is
implementation-defined,
and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h>
header. If the result is not representable in an object of that type, the
behavior is undefined."
So for this reason I believe that folding
PTR +- CST CMP PTR +- CST
(with CST being of pointer type, as represented by the middle-end) as
+- (ptrdiff_t)CST CMP +- (ptrdiff_t)CST
is valid. Now the intel compiler f.i. does _not_ do this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27039
More information about the Gcc-bugs
mailing list