Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
879 Discussions

OpenMP fails on iterator and range based loops in Windows debug builds

Mentzer__Stuart
New Contributor I
42 Views

Using recent (2026, 2025, & 2024) oneAPI C++ on Windows I found that OpenMP parallel for on iterator-based and range-based for loops isn't working in debug builds, but index-based loops work. For example, this demo:

#include <vector>
#include <iostream>

int
main()
{
	std::vector< int > v = {0,1,2,3,4,5,6,7,8,9};

	// Works
	// #pragma omp parallel for
	// for ( std::vector< int >::size_type i = 0; i < v.size(); ++i ) {
	// 	++v[i];
	// }

	// Fails in in debug build at runtime
	#pragma omp parallel for
	for ( std::vector< int >::iterator i = v.begin(); i < v.end(); ++i ) {
		++(*i);
	}

	for ( int i : v ) std::cout << i << std::endl;
}

compiled with:
  icx /nologo /Qopenmp /Qopenmp-simd- /EHsc /Wall /Od /MDd
builds but terminates at runtime, sometimes popping up a dialog with "ITERATOR LIST CORRUPTED". With /MD or /MT it runs fine.

It doesn't appear to be a VC++ standard library limitation because I see the same problem with my own classes, yet I believe this usage worked some years ago.

 Maybe this is a known/documented limitation but I couldn't find any information on it.

0 Kudos
0 Replies
Reply