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 tree-optimization/53265] Warn when undefined behavior implies smaller iteration count


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-07
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-05-07 14:10:48 UTC ---
Confirmed.

It's not so simple as cases I have seen do not involve a statically constant
nb_interations.  Consider

enum {N=4};
int a[N], pfx[N];
void foo(int n)
{
  int i, accum;
  for (i=0, accum=a[0]; i < n; i++, accum+=a[i])
    pfx[i] = accum;
}

and calling that with n == 4.

I was suggesting to warn about optimizing a loop exit test to never stop
iterating.


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