This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/31399] Wrong code for do loop with large interation count
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Mar 2007 11:49:15 -0000
- Subject: [Bug fortran/31399] Wrong code for do loop with large interation count
- References: <bug-31399-10259@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from fxcoudert at gcc dot gnu dot org 2007-03-30 12:49 -------
(In reply to comment #0)
> the loop count should be
> changed from
> count = (to + step - from) / step
> to something else that cannot overflow.
I think it should be:
unsigned count = (step>0 ? to<from : to>from) ? 0 : 1 +
(unsigned)((to-from)/step)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31399