title: Will there be gain in performance in case a big automatic variable is assigned instead of memset in C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/324011/memcpy-vs-assignment-in-c">memcpy vs assignment in C</a>  </p>
  </blockquote>
  
  
  
  <p>I wanted to know if there is a gain in performance of assigning a big structure (e.g 100 bytes) automatic variable to zero rather than doing memset it to zero in run time in C.
  Not sure if gcc compiler can do optimization at compile time for this</p>
  
  <p>Below are the two cases</p>
  
  <p><strong>Case 1:</strong></p>
  
  <pre><code>void fun1()
  {
     struct S y = {0};
  }
  </code></pre>
  
  <p><strong>Case 2:</strong></p>
  
  <pre><code>void fun1()
  {
    struct S y;
    memset(&amp;y, 0, sizeof(y));
  }
  </code></pre>