On Tue, Feb 22, 2005 at 04:32:33PM +0100, Peter Seiderer wrote:
> Thanks, reproducable with intel:
>
> # icc -strict_ansi default_constructor.cpp
> default_constructor.cpp(17): warning #854: const variable "a2" requires an
> initializer -- class "A2" has no explicitly declared default constructor
> static const A2 a2;
> ^
>
> Any hints to relevant documentation?
It's equivalent to this:
const int i;
which is pretty much certain to be an error and the compiler is doing
you a favour if it rejects it.
The ISO standard says (in 8.5 [dcl.init] paragraph 9):
If no initializer is specified for an object, and the object is of
(possibly cv-qualified) non-POD class type (or array thereof), the
object shall be default-initialized; if the object is of
const-qualified type, the underlying class type shall have a
user-declared default constructor.
The second half of that paragraph applies to A2.
jon
--
"A thing is not necessarily true because a man dies for it."
- Oscar Wilde