title: Is using a string constant in C++ ternary operator an invalid use of non-lvalue array?
body: <p>I have code which checks a condition using the ternary operator and then either returns a pointer to a c-string constant or throws an exception.  </p>
  
  <p>Strangely, the compilation only fails when I <code>throw</code> from one path of the ternary operator.  If I put a string constant on both sides everything compiles.</p>
  
  <pre><code>// this line gives no compilation error
  auto str = condition ? "foo" : "bar";
  
  // this line gives "error: invalid use of non-lvalue array"
  auto str = condition ? "foo" : throw std::runtime_error{"bad"};
  </code></pre>
  
  <p>This problem has started showing up in gcc 9.1.  I have used lines with both of the above patterns for many years and they compile without warning in clang and earlier versions of gcc.</p>
  
  <p>Is the above pattern actually invalid, or is this a compiler bug in gcc 9.1?</p>