diff mbox

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

Message ID alpine.LNX.2.00.1302071430230.6889@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Feb. 7, 2013, 1:31 p.m. UTC
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.

Comments

Gerald Pfeifer Feb. 16, 2013, 11:36 p.m. UTC | #1
On Thu, 7 Feb 2013, Richard Biener wrote:
> As promised, a bugs.html entry.

Looks good to me.

Now, at the top of the page we have

  <p>Before reporting that GCC compiles your code incorrectly, compile it
  with <code>gcc -Wall -Wextra</code> and see whether this shows anything
  wrong with your code.  Similarly, if compiling with
  <code>-fno-strict-aliasing -fwrapv</code> makes a difference, your code
  probably is not correct.</p>

Should I add  -fno-aggressive-loop-optimizations  to the list in the
second sentence?

Gerald
Richard Biener Feb. 18, 2013, 9:09 a.m. UTC | #2
On Sun, 17 Feb 2013, Gerald Pfeifer wrote:

> On Thu, 7 Feb 2013, Richard Biener wrote:
> > As promised, a bugs.html entry.
> 
> Looks good to me.
> 
> Now, at the top of the page we have
> 
>   <p>Before reporting that GCC compiles your code incorrectly, compile it
>   with <code>gcc -Wall -Wextra</code> and see whether this shows anything
>   wrong with your code.  Similarly, if compiling with
>   <code>-fno-strict-aliasing -fwrapv</code> makes a difference, your code
>   probably is not correct.</p>
> 
> Should I add  -fno-aggressive-loop-optimizations  to the list in the
> second sentence?

Yes please.

Thanks,
Richard.
diff mbox

Patch

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>