Bug 999674

Summary: Uninitialized internal variable with OpenMP loop collapse
Product: [Fedora] Fedora Reporter: Susi Lehtola <susi.lehtola>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: jakub, law
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-28 10:14:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Susi Lehtola 2013-08-21 20:10:17 UTC
When trying a loop collapse with gcc 4.8.1 I get warnings about unitialized internal variables.

Reduced test case:

#include <cstdlib>
#include <vector>
#include <cstdio>

int main(void) {
  size_t N=10;

#ifdef _OPENMP
#pragma omp parallel for collapse(2)
#endif
  for(size_t iix=0;iix<N;iix++)
    for(size_t iiy=0;iiy<N;iiy++)
      printf("%i\n",(int) (iix+iiy*iiy));

  return 0;
}


No errors arise with -Wall -fopenmp, but with added -O2 


$ g++ -O2 -Wall  -fopenmp test.cpp 
test.cpp: In function ‘<built-in>’:
test.cpp:11:3: warning: ‘.count.6’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   for(size_t iix=0;iix<N;iix++)
   ^
test.cpp:11:3: note: ‘.count.6’ was declared here
   for(size_t iix=0;iix<N;iix++)
   ^
test.cpp:11:3: warning: ‘.count.7’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   for(size_t iix=0;iix<N;iix++)
   ^
test.cpp:11:3: note: ‘.count.7’ was declared here
   for(size_t iix=0;iix<N;iix++)
   ^

Comment 1 Susi Lehtola 2013-08-21 20:26:32 UTC
If you remove the collapse statement, the uninitialized variable doesn't appear.

Comment 2 Jakub Jelinek 2013-08-28 10:14:53 UTC
Fixed upstream, will propagate to F19 when F19 gcc is errataed (in a few weeks).