C++ Constant Expression and Array Bounds
<p>Can someone please explain (what might be my perceived) disparity in errors in the following code? Essentially why are "//OK" okay and "//error" errors?</p>

<p>(Compiler is i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490))</p>

<pre><code>#include &lt;cmath&gt;
#include &lt;iosfwd&gt;

template &lt;typename T&gt;
class TT{
   char _c[sizeof(T) + static_cast&lt;size_t&gt;(::ceil(sizeof(T) * 0.001)) + 1];    // error: array bound is not an integer constant
   //char _c[sizeof(T) + static_cast&lt;size_t&gt;(sizeof(T) * 0.001) + 1];  // OK
   T _t;
};

class IS{
   unsigned char* _u;
   double _d;
};

char s[static_cast&lt;size_t&gt;(::ceil(sizeof(TT&lt;IS&gt;) * 10.0))]; // error: array bound is not an integer constant

int main(int argc, char** argv){
  char a[static_cast&lt;size_t&gt;(10.0)];  // OK
  char b[static_cast&lt;size_t&gt;(::ceil(sizeof(double) * 10.0))]; // OK

  TT&lt;int&gt; it;
  char c[static_cast&lt;size_t&gt;(::ceil(sizeof(TT&lt;int&gt;) * 10.0))];    // OK

  TT&lt;IS&gt; is;
  char d[static_cast&lt;size_t&gt;(::ceil(sizeof(TT&lt;IS&gt;) * 10.0))]; // OK

  return 0;
}
</code></pre>

<p>As a side note, I am aware of C++0x: Generalized constant expression.</p>
