title: Is ‘int main;’ a valid C/C++ program?
body: <p>I ask because my compiler seems to think so, even though I don’t.</p>
  
  <p><code>echo 'int main;' | cc -x c - -Wall</code><br>
  <code>echo 'int main;' | c++ -x c++ - -Wall</code></p>
  
  <p>Clang issues no warning or error with this, and gcc issues only the meek warning: <code>'main' is usually a function [-Wmain]</code>, but only when compiled as C. Specifying a <code>-std=</code> doesn’t seem to matter.</p>
  
  <p>Otherwise, it compiles and links fine. But on execution, it terminates immediately with <code>SIGBUS</code> (for me). </p>
  
  <p>Reading through the (excellent) answers at <a href="https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c">What should main() return in C and C++?</a> and a quick grep through the language specs, it would certainly <strong>seem</strong> to me that a main <em>function</em> is required. But the verbiage from gcc’s <code>-Wmain</code> (‘main’ is <strong><em>usually</em></strong> a function) (and the dearth of errors here) seems to possibly suggest otherwise.</p>
  
  <p>But why? Is there some strange edge-case or “historical” use for this? Anyone know what gives?</p>
  
  <p>My point, I suppose, is that I really think this should be an <strong>error</strong> in a hosted environment, eh?</p>