title: When and how to use GCC's stack protection feature?
body: <p>I have enabled the <code>-Wstack-protector</code> warning when compiling the project I'm working on (a commercial multi-platform C++ game engine, compiling on Mac OS X 10.6 with GCC 4.2).
  This flag warns about functions that will not be protected against stack smashing even though <code>-fstack-protector</code> is enabled.
  GCC emits some warnings when building the project:</p>
  
  <blockquote>
    <p>not protecting function: no buffer at least 8 bytes long<br>
    not protecting local variables: variable length buffer</p>
  </blockquote>
  
  <p>For the first warning, I found that it is possible to adjust the minimum size a buffer must have when used in a function, for this function to be protected against stack smashing: <code>--param ssp-buffer-size=X</code> can be used, where X is 8 by default and can be as low as 1.</p>
  
  <p>For the second warning, I can't suppress its occurrences unless I stop using <code>-Wstack-protector</code>.</p>
  
  <ol>
  <li>When should <code>-fstack-protector</code> be used? (as in, for instance, all the time during dev, or just when tracking bugs down?)  </li>
  <li>When should <code>-fstack-protector-all</code> be used?  </li>
  <li>What is <code>-Wstack-protector</code> telling me? Is it suggesting that I decrease the buffer minimum size?  </li>
  <li>If so, are there any downsides to putting the size to 1?  </li>
  <li>It appears that <code>-Wstack-protector</code> is not the kind of flag you want enabled at all times if you want a warning-free build. Is this right?</li>
  </ol>