title: Definitive List of Common Reasons for Segmentation Faults
body: <blockquote>
    <p>NOTE: We have a lot of segfault questions, with largely the same
    answers, so I'm trying to collapse them into a canonical question like
    we have for <a href="https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix">undefined reference</a>.</p>
    
    <p>Although we have a question covering <a href="https://stackoverflow.com/questions/2346806/what-is-segmentation-fault">what a segmentation fault
    is</a>, it covers the <strong>what</strong>, but doesn't list many reasons. The top answer says "there are many reasons", and only lists one, and most of the other answers don't list any reasons.</p>
    
    <p>All in all, I believe we need a <strong>well-organized community wiki</strong> on this topic, which lists all the common causes (and then some) to get segfaults. The purpose is to aid in debugging, as mentioned in the answer's disclaimer.</p>
  </blockquote>
  
  <p>I know what a segmentation fault is, but it can be hard to spot in the code without knowing what they often look like. Although there are, no doubt, far too many to list exhaustively, <strong>what are the most common causes of segmentation faults</strong> in C and C++?</p>