Infinite loop in dcraw with current GCC versions

dcoffin@shell.cybercom.net dcoffin@shell.cybercom.net
Tue Mar 3 02:32:00 GMT 2015


Hi Manuel,

     Here's the blend_highlights() function from dcraw.c
with just the includes, defines, and globals it needs to
compile.

	gcc -Wall -O4 -march=athlon64 foo.c

     gives two "array bounds" warnings,

	gcc -Wall -O4 -march=x86-64 foo.c
	gcc -Wall -O4 foo.c
	gcc -Wall -O3 foo.c

     give one warning, while "-O2" or less gives no warnings.
Unlike -Wunused-result and -Waggressive-loop-optimizations,
-Warray-bound is not enabled by default, only because I use
-Wall.
				Dave Coffin  3/2/2015

On Mon, Mar 02, 2015 at 12:10:37PM +0100, Manuel López-Ibáñez wrote:
> On 1 March 2015 at 21:03,  <dcoffin@shell.cybercom.net> wrote:
> >      I fixed all the "undefined behavior" warnings with
> > typecasts, but I'm still getting array-bounds warnings
> > with manifestly correct code.  E.g. when blend_highlights()
> > uses the global variable "colors":
> >
> >   static const float trans[2][4][4] = { ... }
> > ...
> >   if ((unsigned) (colors-3) > 1) return;
> > ...
> >   lab[i][c] += trans[colors-3][c][j] * cam[i][j];
> >
> >      How could "colors-3" be out of bounds?  I just verified
> > that it's either 0 or 1, and if I hard-code 0 or 1 the warning
> > goes away.
> 
> Could you post a small complete example? It doesn't need to have a
> main() function and it is better if it doesn't use any header files.
> 
> Cheers,
> 
> Manuel.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 1685 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20150303/05b44d19/attachment.bin>


More information about the Gcc-help mailing list