constexpr if and static_assert
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0292r1.html">P0292R1 constexpr if</a> has been <a href="https://herbsutter.com/2016/06/30/trip-report-summer-iso-c-standards-meeting-oulu/">included</a>, on track for C++17. It seems useful (and can replace use of SFINAE), but a comment regarding <code>static_assert</code> being <em>ill-formed, no diagnostic required</em> in the false branch scares me:</p>

<pre><code>Disarming static_assert declarations in the non-taken branch of a
constexpr if is not proposed.

void f() {
  if constexpr (false)
    static_assert(false);   // ill-formed
}

template&lt;class T&gt;
void g() {
  if constexpr (false)
    static_assert(false);   // ill-formed; no 
               // diagnostic required for template definition
}
</code></pre>

<p>I take it that it's completely forbidden to use <code>static_assert</code> inside constexpr if (at least the false / non-taken branch, but that in practice means it's not a safe or useful thing to do).</p>

<p>How does this come about from the standard text? I find no mentioning of <code>static_assert</code> in the proposal wording, and C++14 constexpr functions do allow <code>static_assert</code> (details at cppreference: <a href="http://en.cppreference.com/w/cpp/language/constexpr">constexpr</a>).</p>

<p>Is it hiding in this new sentence (after 6.4.1) ? : </p>

<blockquote>
  <p>When a constexpr if statement appears in a templated entity, 
     during an instantiation of the enclosing template or generic lambda, 
     a discarded statement is not instantiated.</p>
</blockquote>

<p>From there on, I assume that it is also forbidden, no diagnostic required, to call other constexpr (template) functions which <em>somewhere</em> down the call graph may call <code>static_assert</code>. </p>

<p><strong>Bottom line:</strong> </p>

<p>If my understanding is correct, doesn't that put a quite hard limit on the safety and usefulness of <code>constexpr if</code> as we would have to know (from documentation or code inspection) about any use of <code>static_assert</code>? Are my worries misplaced?</p>

<p><strong>Update:</strong></p>

<p>This code compiles without warning (clang head 3.9.0) but is to my understanding <em>ill-formed</em>, no diagnostic required. Valid or not?</p>

<pre><code>template&lt; typename T&gt;
constexpr void other_library_foo(){
    static_assert(std::is_same&lt;T,int&gt;::value);
}

template&lt;class T&gt;
void g() {
  if constexpr (false)
    other_library_foo&lt;T&gt;(); 
}

int main(){
    g&lt;float&gt;();
    g&lt;int&gt;();
}
</code></pre>