title: What is the definition for gamma(double x) and why is it different on two gcc versions?
body: <p>Through unfortunate circumstances I have discovered that my standard library implementations  <code>&lt;math.h&gt;</code> and <code>&lt;cmath&gt;</code>(C++) apparently contain a definition for a function with a prototype like:</p>
  
  <pre><code>double gamma(double x);
  </code></pre>
  
  <p>Though I do not see it listed anywhere in the language standard (draft I have access to).</p>
  
  <p>Using gcc v4.2.1 on Mac OS X that function evaluates the same as <code>tgamma</code> which is actually the name given to it in the standard. <a href="http://www.cplusplus.com/reference/cmath/tgamma/" rel="nofollow">(reference)</a></p>
  
  <p>But on gcc v4.6.3 on Ubuntu 12.04 that function evaluates to something different.</p>
  
  <p>I don't understand why a function named <code>gamma</code> compiles at all, but why is the result not the same between compilers?</p>
  
  <p>Here is a simple test program:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;sstream&gt;
  #include&lt;math.h&gt; // or &lt;cmath&gt;
  
  int main(int argc, char **argv)
  {
      std::stringstream conversionStream(argv[1]);
      double input;
      conversionStream &gt;&gt; input;
      std::cout &lt;&lt; "gamma( " &lt;&lt; input &lt;&lt; " ) = " &lt;&lt; gamma(input) &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Compile and run with 1 argument:</p>
  
  <pre><code>$ g++ -o gamma_test gamma_test.cpp 
  $ ./gamma_test 1.0
  gamma( 1 ) = 1
  </code></pre>
  
  <p>But the output on Ubuntu gcc v4.6.3 is 0!</p>