title: Simplest fix for "error: taking the address of a temporary object"?
body: <pre><code>struct context* ctx = &amp;(struct context){ 0 };
  </code></pre>
  <p>I am trying to use <code>clang++</code> C++ compiler to compile C code, possibly with minimal code changes.</p>
  <p>For the above code I get error:</p>
  <p><code>error: taking the address of a temporary object of type 'struct context' [-Waddress-of-temporary]</code></p>
  <ol>
  <li>Is there a compiler switch to make it tolerate such constructs?</li>
  <li>What's the smallest code change to make such code compile using<code>clang++</code>? Maybe the following?</li>
  </ol>
  <p><em>a)</em></p>
  <pre><code>    struct context* ctx;   
      struct context tmp = { 0 };
      ctx = &amp;(tmp);
  </code></pre>
  <p><em>b)</em></p>
  <pre><code>    struct context* ctx;   
      {
          struct context tmp = { 0 };
          ctx = &amp;(tmp);
      }
  </code></pre>
  <p>Note:</p>
  <ul>
  <li><code>-std=c++2a</code> option is used when compiling</li>
  <li><code>clang++</code> seems to tolerate (support?) designated initializers</li>
  <li>option <em>b)</em> also compiles fine</li>
  </ul>