[GRASS-dev] [GRASS GIS] #2787: grass-7.0.1: compiling on Gentoo shows warnings when built with -Wagressive-loop-optimizations

GRASS GIS trac at osgeo.org
Thu Oct 29 15:41:35 PDT 2015


#2787: grass-7.0.1: compiling on Gentoo shows warnings when built with
-Wagressive-loop-optimizations
--------------------------+-------------------------
  Reporter:  wraeth       |      Owner:  grass-dev@…
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:
 Component:  Compiling    |    Version:  7.0.1
Resolution:               |   Keywords:
       CPU:  x86-64       |   Platform:  Linux
--------------------------+-------------------------

Comment (by glynn):

 Replying to [ticket:2787 wraeth]:

 >  * main.c:312:2: warning: iteration 14u invokes undefined behavior
 [-Waggressive-loop-optimizations]
 >  * main.c:308:6: warning: iteration 14u invokes undefined behavior
 [-Waggressive-loop-optimizations]
 >  * main.c:278:6: warning: iteration 14u invokes undefined behavior
 [-Waggressive-loop-optimizations]

 imagery/i.aster.toar/main.c

 {{{
 77  /*File Descriptors */
 78  int infd[MAXFILES];
 79  int outfd[MAXFILES];
 }}}

 {{{
 277     for (i = 1; i <= MAXFILES; i++)
 278         Rast_get_row(infd[i], inrast[i-1], row, in_data_type[i-1]);
 }}}

 {{{
 307     for (i = 1; i <= MAXFILES; i++)
 308         Rast_put_row(outfd[i], outrast[i-1], out_data_type);
 }}}

 {{{
 310 for (i = 1; i <= MAXFILES; i++) {
 311     G_free(inrast[i-1]);
 312     Rast_close(infd[i]);
 313     G_free(outrast[i-1]);
 314     Rast_close(outfd[i]);
 315 }
 }}}

 i can be equal to MAXFILES, which is the side of infd and outfd, so
 accessing infd[i] and outfd[i] is undefined behaviour.

 >  * aerosolmodel.cpp:619:59: warning: iteration 82u invokes undefined
 behavior [-Waggressive-loop-optimizations]

 imagery/i.atcorr/common.h

 {{{
 51      float phasel[10][83];
 }}}

 imagery/i.atcorr/aerosolmodel.cpp

 {{{
 619     for (int k = 1; k <= 83; ++k) sixs_sos.phasel[i][k] = 0.f;
 }}}

 Similar issue.

 Was this converted from Fortran?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2787#comment:2>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list