This is the mail archive of the gcc-patches@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]

[PATCH][www] Add loop case to non-bugs in bugs.html


As promised, a bugs.html entry.

Ok?

Thanks,
Richard.

2013-02-07  Richard Biener  <rguenther@suse.de>

	* bugs/index.html: Add "Loops do not terminate" case to non-bugs.

Index: index.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/bugs/index.html,v
retrieving revision 1.109
diff -u -r1.109 index.html
--- index.html	10 Oct 2012 15:52:29 -0000	1.109
+++ index.html	7 Feb 2013 13:29:39 -0000
@@ -429,6 +429,32 @@
 article</a>.</p></dd>
 
 
+<dt>Loops do not terminate</dt>
+<dd><p>This is often caused by out-of-bound array accesses or by signed integer
+overflow which both result in undefined behavior according to the ISO
+C standard.  For example</p>
+
+<blockquote><pre>
+int
+SATD (int* diff, int use_hadamard)
+{
+  int k, satd = 0, m[16], dd, d[16];
+  ...
+    for (dd=d[k=0]; k&lt;16; dd=d[++k])
+      satd += (dd &lt; 0 ? -dd : dd);
+</pre></blockquote>
+
+<p>accesses <code>d[16]</code> before the loop is exited with
+the <code>k&lt;16</code> check.  This causes the compiler to
+optimize away the exit test because the new value of <code>k</code>
+must be in the range <code>[0, 15]</code> according to ISO C.</p>
+
+<p>GCC starting with version 4.8 has a new option
+<code>-fno-aggressive-loop-optimizations</code> that may help here.
+If it does, then this is a clear sign that your code is not conforming
+to ISO C and it is not a GCC bug.</p></dd>
+
+
 <dt>Cannot use preprocessor directive in macro arguments.</dt>
 <dd><p>Let me guess... you used an older version of GCC to compile code
 that looks something like this:</p>


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