title: Why is this narrowing conversion not detected?
body: <p>when constructing variables using the list-initialization (like <code>int x{ 5 };</code>) <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf" rel="noreferrer">the standard</a> §8.5.4 says:</p>
  
  <blockquote>
    <p>If a narrowing conversion […] is required to convert any of the arguments, the program is ill-formed. 
     <Sub>(7)</Sub> A narrowing conversion is an implicit conversion -
    <Sub>(7.4)</Sub> from an integer type or unscoped enumeration type to an integer type that cannot represent all the values of the original type, except where the source is a constant expression whose value after integral promotions will ﬁt into the target type. </p>
  </blockquote>
  
  <p>So why does this compile?</p>
  
  <pre><code>char c{ 'A' };
  char x{ c + c };
  </code></pre>
  
  <hr>
  
  <p>As a reminder, <code>c + c</code> yields an <code>int</code> </p>
  
  <pre><code>static_assert(std::is_same_v&lt;decltype(c + c), int&gt;, "");
  </code></pre>
  
  <p>so the compiler should complain about a narrowing conversion which is certainly not a constant expression.</p>
  
  <hr>
  
  <p>Interestingly, declaring <code>x</code> to be an <code>unsigned char</code> correctly fails to compile:</p>
  
  <pre><code>char c{ 'A' };
  unsigned char x{ c + c }; 
  </code></pre>
  
  <blockquote>
    <p>C2397 conversion from 'int' to 'unsigned char' requires a narrowing conversion    </p>
  </blockquote>
  
  <p>As does introducing a temporary:</p>
  
  <pre><code>char c{ 'A' };
  int sum{ c + c };
  char x{ sum }; //C2397 conversion from 'int' to 'char' requires [...]
  </code></pre>
  
  <hr>
  
  <p>So why does the first version compile? I'm using Visual Studio Community 2017 Version 15.9.5 and compile it with <code>/wall</code> and all warnings are errors enabled in a <code>x64</code> debug build. Setting the standard C++11, C++14 and C++17 all compile. </p>
  
  <hr>
  
  <p><strong>I filed the bug report <a href="https://developercommunity.visualstudio.com/content/problem/613834/compiler-allows-specific-narrowing-conversion.html" rel="noreferrer">here</a></strong></p>