Struct member as loop bound error

Hi,
I noticed a strange behavior when using a struct member as a loop bound, in particular:
ignoring OpenACC pragmas (and thus running in the CPU), both of the code versions reported below, work, giving the same results;
on the other side, when enabling OpenACC prgmas, the first version gives wrong results, while the second one gives correct results as the ones run on the CPU.

Am I doing something not allowed using OpenACC in the first code version?
Or both the versions should be equivalent and the compiler is doing something wrong when compiling the second one?

Code version one:

void recombine_shifted_vec3_to_vec3(const __restrict vec3_soa* const in_shifted
                                                        const __restrict vec3_soa* const in,
                                                                __restrict vec3_soa* const out,
                                                        const RationalApprox * const approx ){
  int ih;
  int iter=0;
  #pragma acc kernels present(out) present(in) present(in_shifted) present(approx)
  #pragma acc loop independent
  for(ih=0; ih < sizeh; ih++){

      out->c0[ih] =  in->c0[ih]*approx->RA_a0;
      out->c1[ih] =  in->c1[ih]*approx->RA_a0;
      out->c2[ih] =  in->c2[ih]*approx->RA_a0;

      #pragma acc seq
      for(iter=0; iter<(approx->approx_order); iter++){ 
        out->c0[ih] +=  approx->RA_a[iter] * in_shifted[iter].c0[ih];
        out->c1[ih] +=  approx->RA_a[iter] * in_shifted[iter].c1[ih];
        out->c2[ih] +=  approx->RA_a[iter] * in_shifted[iter].c2[ih];
      }
   }
}

Code version two:

void recombine_shifted_vec3_to_vec3(const __restrict vec3_soa* const in_shifted
                                                        const __restrict vec3_soa* const in,
                                                                __restrict vec3_soa* const out,
                                                        const RationalApprox * const approx ){
  int ih;
  int iter=0;
  #pragma acc kernels present(out) present(in) present(in_shifted) present(approx)
  #pragma acc loop independent
  for(ih=0; ih < sizeh; ih++){

      int ordine=approx->approx_order;

      out->c0[ih] =  in->c0[ih]*approx->RA_a0;
      out->c1[ih] =  in->c1[ih]*approx->RA_a0;
      out->c2[ih] =  in->c2[ih]*approx->RA_a0;

      #pragma acc seq
      for(iter=0; iter<ordine; iter++){ 
        out->c0[ih] +=  approx->RA_a[iter] * in_shifted[iter].c0[ih];
        out->c1[ih] +=  approx->RA_a[iter] * in_shifted[iter].c1[ih];
        out->c2[ih] +=  approx->RA_a[iter] * in_shifted[iter].c2[ih];
      }
   }
}

Hi EnricoC,

What compiler version are you using?

I found a similar problem myself early this year and our compiler folks were able to fix it in the 15.4 release. If 15.4 doesn’t fix your issue, can you please post or send to PGI Customer Service (trs@pgroup.com) a reproducing example so I can investigate?

Thanks,
Mat