<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Thema "Re: OpenMP fails on iterator and range based loops in Windows debug builds" in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753630#M4781</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/48520"&gt;@Sravani_K_Intel&lt;/a&gt;&amp;nbsp;. This is sort of what I expected.&lt;/P&gt;&lt;P&gt;Note that I used&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;/Qopenmp-simd-&amp;nbsp; to suppress that simd warning and then it gives no warnings. I appreciate that the warnings (and documentation?) on this will be improved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For my purposes, the "hardened" standard library you get with /MDd or /MTd are more important in debug builds that enabling OpenMP so I'll just drop&amp;nbsp;&amp;nbsp;/Qopenmp&amp;nbsp; from my normal debug builds. But I can see that it could be useful for some projects to add an OpenMP debug build type that enables OpenMP but uses /MD or /MT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I wonder if this will become a wider issue as options to use a "hardened" version of other C++ standard libraries are released. The Clang++ hardening modes do not alter the ABI of the library but the full GCC debug mode does.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jul 2026 18:56:28 GMT</pubDate>
    <dc:creator>Mentzer__Stuart</dc:creator>
    <dc:date>2026-07-10T18:56:28Z</dc:date>
    <item>
      <title>OpenMP fails on iterator and range based loops in Windows debug builds</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753182#M4768</link>
      <description>&lt;P&gt;Using recent (2026, 2025, &amp;amp; 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:&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;vector&amp;gt;
#include &amp;lt;iostream&amp;gt;

int
main()
{
	std::vector&amp;lt; int &amp;gt; v = {0,1,2,3,4,5,6,7,8,9};

	// Works
	// #pragma omp parallel for
	// for ( std::vector&amp;lt; int &amp;gt;::size_type i = 0; i &amp;lt; v.size(); ++i ) {
	// 	++v[i];
	// }

	// Fails in in debug build at runtime
	#pragma omp parallel for
	for ( std::vector&amp;lt; int &amp;gt;::iterator i = v.begin(); i &amp;lt; v.end(); ++i ) {
		++(*i);
	}

	for ( int i : v ) std::cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; std::endl;
}&lt;/LI-CODE&gt;&lt;P&gt;compiled with:&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; icx /nologo /Qopenmp /Qopenmp-simd- /EHsc /Wall /Od /MDd&lt;BR /&gt;builds but terminates at runtime, sometimes popping up a dialog with "ITERATOR LIST CORRUPTED". With /MD or /MT it runs fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Maybe this is a known/documented limitation but I couldn't find any information on it.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jul 2026 11:59:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753182#M4768</guid>
      <dc:creator>Mentzer__Stuart</dc:creator>
      <dc:date>2026-07-06T11:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP fails on iterator and range based loops in Windows debug builds</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753537#M4775</link>
      <description>&lt;P&gt;Additional information...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using oneAPI 2026.1 on Linux (Ubuntu 2026.04), the&amp;nbsp;iterator-based and range-based loops work in debug builds with OpenMP enabled, such as when compiled with:&lt;BR /&gt;&amp;nbsp; icpx -fiopenmp -Wall -O0 -debug&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And using Clang bundled with oneAPI, the&amp;nbsp;iterator-based and range-based loops also work on Windows when compiled with:&lt;BR /&gt;&amp;nbsp; clang++ -fopenmp -Wall -O0 -g&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the issue appears to be limited to the Intel C++ OpenMP support on Windows.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2026 02:13:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753537#M4775</guid>
      <dc:creator>Mentzer__Stuart</dc:creator>
      <dc:date>2026-07-10T02:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP fails on iterator and range based loops in Windows debug builds</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753626#M4780</link>
      <description>&lt;P&gt;Thank you for reporting this issue and providing clear reproduction steps. I can confirm this is a known limitation when using OpenMP with MSVC debug builds (`/MDd`, `/MTd`), not a compiler bug. The issue stems from an incompatibility between:&lt;/P&gt;
&lt;P&gt;1. &lt;STRONG&gt;MSVC debug iterators:&lt;/STRONG&gt; In debug builds, MSVC's STL iterators contain additional metadata for container ownership tracking, bounds checking, and iterator validation (~24-32 bytes vs. 8 bytes in release)&lt;/P&gt;
&lt;P&gt;2. &lt;STRONG&gt;OpenMP privatization:&lt;/STRONG&gt; When OpenMP privatizes the loop variable `i` across threads, it performs a bitwise copy but doesn't update the iterator's internal debug metadata&lt;/P&gt;
&lt;P&gt;3. &lt;STRONG&gt;Race condition&lt;/STRONG&gt;: Multiple threads end up with private iterators that share the same debug metadata structures, leading to concurrent modification and corruption&lt;/P&gt;
&lt;P&gt;This manifests as:&lt;BR /&gt;- "ITERATOR LIST CORRUPTED" dialog&lt;BR /&gt;- Segmentation faults&lt;BR /&gt;- Crashes only in debug builds (`/MDd`, `/MTd`)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may have noticed this warning:&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;warning: using /MTd or /MDd with '#pragma omp simd' may lead to unexpected fails due to the debugging version of iterators [-Wdebug-option-simd]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;While this mentions `#pragma omp simd` specifically, the issue affects all OpenMP constructs that privatize iterators, including `#pragma omp parallel for`. We will work on enhancing this warning message to be more comprehensive and also document this as a known issue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This limitation exists with any compiler that properly uses MSVC's debug runtime.&amp;nbsp;You mentioned this works with `clang++ -fopenmp`. That's true, but it's not because clang++ handles the issue better it's because:&lt;/P&gt;
&lt;P&gt;1. Clang++ on Windows has difficulty linking with MSVC's debug runtime(`/MDd`)&lt;BR /&gt;2. When you compile with `clang++ -fopenmp` (even with `-g`), it typically uses the release version of MSVC STL&lt;BR /&gt;3. Without debug iterators enabled (`_ITERATOR_DEBUG_LEVEL=2`), there's no metadata to corrupt&lt;BR /&gt;4. You can verify this: try `clang++ -fopenmp -D_DEBUG -D_ITERATOR_DEBUG_LEVEL=2` and you'll get linking errors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may temporarily disable iterator debugging by adding&amp;nbsp; #define _ITERATOR_DEBUG_LEVEL 0&amp;nbsp; before any STL includes or compile with&amp;nbsp;/D_ITERATOR_DEBUG_LEVEL=0 but this will disable all iterator&amp;nbsp;safety checks in your debug build, which may hide other iterator-related bugs. The recommended practice would be to use index-based loops with OpenMP on Windows.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2026 18:30:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753626#M4780</guid>
      <dc:creator>Sravani_K_Intel</dc:creator>
      <dc:date>2026-07-10T18:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: OpenMP fails on iterator and range based loops in Windows debug builds</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753630#M4781</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/48520"&gt;@Sravani_K_Intel&lt;/a&gt;&amp;nbsp;. This is sort of what I expected.&lt;/P&gt;&lt;P&gt;Note that I used&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;/Qopenmp-simd-&amp;nbsp; to suppress that simd warning and then it gives no warnings. I appreciate that the warnings (and documentation?) on this will be improved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For my purposes, the "hardened" standard library you get with /MDd or /MTd are more important in debug builds that enabling OpenMP so I'll just drop&amp;nbsp;&amp;nbsp;/Qopenmp&amp;nbsp; from my normal debug builds. But I can see that it could be useful for some projects to add an OpenMP debug build type that enables OpenMP but uses /MD or /MT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I wonder if this will become a wider issue as options to use a "hardened" version of other C++ standard libraries are released. The Clang++ hardening modes do not alter the ABI of the library but the full GCC debug mode does.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2026 18:56:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/OpenMP-fails-on-iterator-and-range-based-loops-in-Windows-debug/m-p/1753630#M4781</guid>
      <dc:creator>Mentzer__Stuart</dc:creator>
      <dc:date>2026-07-10T18:56:28Z</dc:date>
    </item>
  </channel>
</rss>

