title: Different behavior of MSVC and clang for if constexpr branches
body: <p>Given this helper function:</p>
  <pre><code>template&lt;typename Type&gt;
  std::string toString(Type const&amp; value, bool encloseInQuotes = false) {
    if constexpr (std::is_same&lt;bool, Type&gt;::value) {
      auto s = value ? &quot;true&quot; : &quot;false&quot;;
      return encloseInQuotes ? &quot;\&quot;&quot;s + s + &quot;\&quot;&quot; : s;
    }
  
    if constexpr (std::is_arithmetic&lt;Type&gt;::value) {
      if (std::isnan(value)) {
        return encloseInQuotes ? &quot;\&quot;NaN\&quot;&quot; : &quot;NaN&quot;;
      }
    }
  
    return &quot;&quot;;
  }
  </code></pre>
  <p>which is supposed to convert basic types (and strings) to a string expression, I get a compilation error with MSVC when using it like this:</p>
  <pre><code>int main() {
    std::string temp = toString(true);
    return 0;
  }
  </code></pre>
  <p>With clang this compiles without any problem, with MSVC however I get this:</p>
  <blockquote>
  <p>2&gt;c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\math.h(403): error C2668: 'fpclassify': ambiguous call to overloaded function</p>
  <p>2&gt;c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\math.h(288): note: could be 'int fpclassify(long double) noexcept'</p>
  <p>2&gt;c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\math.h(283): note: or       'int fpclassify(double) noexcept'</p>
  <p>2&gt;c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\math.h(278): note: or       'int fpclassify(float) noexcept'</p>
  <p>2&gt;c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\math.h(403): note: while trying to match the argument list '(_Ty)'</p>
  <p>2&gt;        with</p>
  <p>2&gt;        [</p>
  <p>2&gt;            _Ty=int</p>
  <p>2&gt;        ]</p>
  <p>2&gt;: note: see reference to function template instantiation 'bool isnan(_Ty) noexcept' being compiled</p>
  <p>2&gt;        with</p>
  <p>2&gt;        [</p>
  <p>2&gt;            Type=int,</p>
  <p>2&gt;            _Ty=int</p>
  <p>2&gt;        ]</p>
  </blockquote>
  <p>Obviously the compiler considers the <code>if constexpr (std::is_arithmetic&lt;Type&gt;::value)</code> test as valid alternative too and generates the mentioned error. However, at runtime it correctly takes the path for bool (when I leave out the <code>if constexpr (std::is_arithmetic&lt;Type&gt;::value)</code> part or use a cast <code>if (std::isnan(static_cast&lt;double&gt;(value)))</code>).</p>
  <p>How can I make this compile correctly on Windows as well?</p>