title: Compiler test cases or how to test a compiler
body: <p>Compilers like all software, would also be prone to bugs, logical errors.</p>
  
  <p>How does one validate the output generated by the compiler. Typically, my question is(are)</p>
  
  <ul>
  <li><p>How to validate that the machine code generated is correct?</p></li>
  <li><p>How to ensure that the machine code generated is according to the language specification.</p></li>
  <li><p>Does it make sense to just pick an open source project (in C if one is also writing a compiler in C) to just compile it through the "compiler". In that case also, how do judge that the compiler is behaving as expected. </p></li>
  <li><p>Are there any formal test cases (literature) provided by the language standards committee that a "language complying" compiler has to satisfy? </p></li>
  <li><p>What are the sure "give aways" that the problem in a program compiled by a <em>compiler</em> is a compiler bug and not a program bug.</p>
  
  <p><strong>- Any examples where mainstream compilers get confused and compile the code wrong?</strong></p></li>
  </ul>
  
  <p>Links to any literature would be appreciated.</p>