This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/31399] Wrong code for do loop with large interation count



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]