title: Can an out-of-range enum conversion produce a value outside the underlying type?
body: <p>Consider the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  enum class E : bool { A, B };
  
  void foo(E e)
  {
      switch(e)
      {
      case E::A: break;
      case E::B: break;
      default: std::cout &lt;&lt; "aha\n";
      }
  }
  
  int main()
  {
      foo( static_cast&lt;E&gt;(3) );
  }
  </code></pre>
  
  <p>My question is: Can the <code>default</code> case be triggered, i.e. this program generates output?</p>
  
  <p>The tricky point in N3936 seems to be the specification of <code>static_cast</code> when converting an out-of-range integer to enumeration type, [expr.static.cast]/10:</p>
  
  <blockquote>
    <p>A value of integral or enumeration type can be explicitly converted to an enumeration type. The value is unchanged if the original value is within the range of the enumeration values. Otherwise, the resulting
    value is unspecified <strong>(and might not be in that range)</strong>.</p>
  </blockquote>
  
  <p>The bolded text does not explicitly say that the value must still be within the range of the underlying type, but I am wondering if it were intended that it did.</p>