This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/40679] Optimizer handles loops with volatiles and post-incr. wrong
- From: "mikpe at it dot uu dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2009 09:59:08 -0000
- Subject: [Bug tree-optimization/40679] Optimizer handles loops with volatiles and post-incr. wrong
- References: <bug-40679-17922@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from mikpe at it dot uu dot se 2009-07-08 09:59 -------
(In reply to comment #2)
> Replacing *tbl++ by tbl[i] gives this ARM code:
> .L2:
> mov r3, #10
> str r3, [r2], #4
> cmp r2, #0
> bne .L2
> bx lr
>
> See, gcc knows about the wrapping but still the *tbl++ version misses the
> end-condition which is the bug.
The difference is that in the tbl[i] version there will not be a wraparound at
runtime because &tbl[i] for i == 64 is never computed, while in the *tbl++
version the iteration with i == 63 will do tbl++ moving tbl from -4U to 0
before the loop termination test, which triggers undefined behaviour.
And the issue is not ARM, the same infinite loop occurs for e.g. target i686.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40679