Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7953 Discussions

Intel Compiler C++ 2022 will not compile openMP code that classic 19.2 does

AndrewC
New Contributor III
868 Views

The simplified code below will not compile with Intel Compiler C++ 2022 ( C++17 and OpenMP on , obviously).

It compiles with classic 19.2 and runs correctly.

1>ConsoleApplication2.cpp(28,14): : error : reference to local binding 'a' declared in enclosing context

1>                                                DoTask(a, aa);

1>                                                       ^

1>ConsoleApplication2.cpp(21,22): note: 'a' declared here

1>                        for (const auto& [a, b] : data)

 

#include <iostream>
#include <tuple>
#include <vector>

std::vector<std::pair<int, std::vector<int>>> data;


void DoTask(int a, int b)
{

}
void test()
{
#	pragma omp parallel
	{
#	pragma omp single
		{
			for (const auto& [a, b] : data)
			{
				for (const auto& aa : b)
				{
					if (aa != a)
					{
#	pragma omp task
						DoTask(a, aa);
					}
				}
			}
		}
	}
}

 

 

The workaround is to use functionally identical code that avoids using the C++17 syntactic sugar

void test2()
{
#	pragma omp parallel
	{
#	pragma omp single
		{
			for ( auto iter =data.begin(); iter!=data.end(); ++iter)
			{
				const auto &a=iter->first;
				const auto &b=iter->second;
				for (const auto& aa : b)
				{
					if (aa != a)
					{
#	pragma omp task
						DoTask(a, aa);
					}
				}
			}
		}
	}
}

 

0 Kudos
1 Solution
Viet_H_Intel
Moderator
793 Views

Thanks for letting us known this bug. This is a know issue. See https://bugs.llvm.org/show_bug.cgi?id=33678.

Since there is a workaround and hopefully this bug will be addressed in llvm community at some point, can we close this thread for now?


Regards,


View solution in original post

0 Kudos
5 Replies
NoorjahanSk_Intel
Moderator
835 Views

Hi,


Thanks for reaching out to us.


We are also able to reproduce the issue from our end.

We are looking into it. We will get back to you soon.


Thanks & Regards,

Noorjahan.


0 Kudos
AndrewC
New Contributor III
825 Views

This compilation error is also present in official Clang 13.0

0 Kudos
Viet_H_Intel
Moderator
794 Views

Thanks for letting us known this bug. This is a know issue. See https://bugs.llvm.org/show_bug.cgi?id=33678.

Since there is a workaround and hopefully this bug will be addressed in llvm community at some point, can we close this thread for now?


Regards,


0 Kudos
AndrewC
New Contributor III
786 Views

Please close it , I see it has been a bug in Clang for a long time. Very annoying they do not fix it. I reported it again in the clang GitHub issues page

0 Kudos
Viet_H_Intel
Moderator
782 Views

Thank. This thread will no longer be monitored by Intel. If you need further assistance, please post a new question.


0 Kudos
Reply