title: How to declare a constant expression correctly?
body: <p>I'm reading <a href="https://rads.stackoverflow.com/amzn/click/com/0321563840" rel="nofollow noreferrer" rel="nofollow noreferrer">The C++ Programming Language</a> and trying to understand <code>Constants</code>. The book says this is valid:</p>
  
  <pre><code>const int dmv = 17; // dmv is a named constant
  constexpr double max1 = 1.4∗square(dmv); // OK if square(17) is a constant expression
  </code></pre>
  
  <p>But when I do:</p>
  
  <pre><code>constexpr double square(double x)
  {
      return x * x;
  }
  
  int main()
  { 
      const double x = 40.0;
      constexpr double result = 1.2 + square(x);
  }
  </code></pre>
  
  <p>I got two errors:</p>
  
  <ol>
  <li><em>expression must have a constant value</em> (in <code>x</code>, if I replace it with a value for ex. <code>12.4</code> like <code>square(12.4)</code> the error disappears)</li>
  <li><em>function call must have a constant value in a constant expression</em> (in square method call.)</li>
  </ol>
  
  <p>What is the reason of those errors ? What am I missing ? </p>