Message ID | alpine.LNX.2.00.1302071430230.6889@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
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
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.
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<16; dd=d[++k]) + satd += (dd < 0 ? -dd : dd); +</pre></blockquote> + +<p>accesses <code>d[16]</code> before the loop is exited with +the <code>k<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>