This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 May 2012 14:10:48 +0000
- Subject: [Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count
- Auto-submitted: auto-generated
- References: <bug-53265-4@http.gcc.gnu.org/bugzilla/>
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.