title: OpenMP min reduction and std::min
body: <p>I am testing OpenMP min reduction. If I write my code like the following, it will return the correct result: res = 3.</p>
  
  <pre><code>#include &lt;omp.h&gt;
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  
  int main(){
  
      omp_set_num_threads(5);
  
      float res=10;
  
  #pragma omp parallel for default(shared) reduction(min:res)
      for(int i1 = 0; i1 &lt;= 10; i1++)
          for(int i0 = 0; i0 &lt;= 10; i0++)
              if(res &gt; 3.0+i1+20*i0)
                  res = 3.0+i1+20*i0;
  
      std::cout &lt;&lt; "res = " &lt;&lt; res &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>But If I write in an alternative way by replacing "if" statement with "std::min", then the result is wrong: res = 10.</p>
  
  <pre><code>#include &lt;omp.h&gt;
  #include &lt;iostream&gt;
  #include &lt;algorithm&gt;
  
  int main(){
  
      omp_set_num_threads(5);
  
      float res=10;
  
  #pragma omp parallel for default(shared) reduction(min:res)
      for(int i1 = 0; i1 &lt;= 10; i1++)
          for(int i0 = 0; i0 &lt;= 10; i0++)
              res = std::min(res,static_cast&lt;float&gt;(3.0+i1+20*i0));
  
      std::cout &lt;&lt; "res = " &lt;&lt; res &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Is OpenMP min reduction interfering with std::min?</p>