title: Why does sqrt() work fine on an int variable if it is not defined for an int?
body: <p>In chapter 3 of <em><a href="http://www.stroustrup.com/Programming/index.html">Programming: Principles and Practice using C++</a></em> (sixth printing), Stroustrup states (p.68): <strong>"Note that <code>sqrt()</code> is not defined for an <code>int</code>"</strong>.</p>
  
  <p>Here is a simple C++ program based on that chapter:</p>
  
  <pre><code>#include "std_lib_facilities.h"
  
  int main()
  {
      int n = 3;
      cout &lt;&lt; "Square root of n == " &lt;&lt; sqrt(n) &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>Given the quote above, I would expect the process of compiling or running this program to fail in some way.</p>
  
  <p>To my surprise, compiling it (with g++ (GCC) 4.2.1) and running it succeeded without errors or warnings, and produced the following perfectly decent output:</p>
  
  <pre><code>Square root of n == 1.73205
  </code></pre>
  
  <p>My question therefore is: if <code>sqrt()</code> really is not defined for an <code>int</code>, then why doesn't the program above fail somehow?</p>