Opened 9 years ago

Closed 7 years ago

#2787 closed defect (fixed)

grass-7.0.1: compiling on Gentoo shows warnings when built with -Wagressive-loop-optimizations

Reported by: wraeth Owned by: grass-dev@…
Priority: normal Milestone: 7.4.0
Component: Compiling Version: 7.0.1
Keywords: i.aster.toar Cc:
CPU: x86-64 Platform: Linux

Description

  • QA Notice: Package triggers severe warnings which indicate that it
  • may exhibit random runtime failures.
  • 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]
  • aerosolmodel.cpp:619:59: warning: iteration 82u invokes undefined behavior [-Waggressive-loop-optimizations]

This appears to be coming from the files:

imagery/i.aster.toar/main.c imagery/i.atcorr/aerosolmodel.cpp

Compile log to follow.

Attachments (1)

grass-7.0.1:201510300002.log.gz (161.5 KB ) - added by wraeth 9 years ago.
Compressed build output

Download all attachments as: .zip

Change History (13)

by wraeth, 9 years ago

Compressed build output

comment:1 by wraeth, 9 years ago

Formatting messed the lines. The errors are produced when compiling the files imagery/i.aster.toar/main.c and imagery/i.atcorr/aerosolmodel.cpp

in reply to:  description ; comment:2 by glynn, 9 years ago

Replying to 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 size 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?

Last edited 9 years ago by glynn (previous) (diff)

in reply to:  2 comment:3 by neteler, 9 years ago

Milestone: 7.0.1

Replying to glynn:

Was this converted from Fortran?

Yes, long time back.

comment:4 by neteler, 9 years ago

Keywords: i.aster.toar added
Milestone: 7.0.17.0.3

comment:5 by neteler, 9 years ago

Milestone: 7.0.3

Ticket retargeted after milestone closed

comment:6 by neteler, 9 years ago

Milestone: 7.0.4

Ticket retargeted after 7.0.3 milestone closed

comment:7 by martinl, 9 years ago

Milestone: 7.0.47.0.5

comment:8 by martinl, 8 years ago

Milestone: 7.0.57.3.0

comment:9 by martinl, 8 years ago

Milestone: 7.3.07.4.0

Milestone renamed

comment:10 by neteler, 7 years ago

Milestone: 7.4.07.4.1

Ticket retargeted after milestone closed

comment:11 by martinl, 7 years ago

What is status of this issue?

comment:12 by neteler, 7 years ago

Milestone: 7.4.17.4.0
Resolution: fixed
Status: newclosed
Type: enhancementdefect

I have now compiled relbranch74 (a.k.a. 7.4.0) with -Waggressive-loop-optimizations and the above reported i.atcorr compilation issues are fixed after Markus Metz's latest improvements.

Closing, feel free to reopen if needed.

Note: See TracTickets for help on using tickets.