https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123597
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
A different case is if it is
template<typename T>
void with_template (T *A)
{
#pragma omp parallel
#pragma omp taskloop collapse(2)
for (long i = 0; i < N; i++)
for (long j = 0; j < N; j++)
{
T sum = 0;
for (long k = 0; k < N; k++)
sum += 2;
A[i + N*j] = sum;
}
}
then that commit indeed has undesirable effects, before it sum was inside of
taskloop body, since that commit it is outside of that and we get
#pragma omp taskloop private(D.3041) private(D.3040) collapse(2)
for (D.3040 = 0; D.3040 < D.3028; D.3040 = D.3040 + 1)
for (D.3041 = 0; D.3041 < D.3030; D.3041 = D.3041 + 1)
{
{
#pragma omp taskloop firstprivate(D.3030) firstprivate(D.3028)
firstprivate(sum) private(j) private(i) shared(A)
{
#pragma omp taskloop collapse(2)
and so firstprivatize a var without initializer (not wrong code, but missed
optimization here I'd say).