This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
default-initialization (was Re: partly bracketed initializer ?)
- To: egcs at egcs dot cygnus dot com
- Subject: default-initialization (was Re: partly bracketed initializer ?)
- From: Bob McWhirter <bob at werken dot com>
- Date: Sat, 20 Feb 1999 15:17:24 -0500 (EST)
On 20 Feb 1999, Alexandre Oliva wrote:
> [dcl.init.aggr]/7 says that aggregate members that are not explicitly
> initialized shall be default-initialized. Default initialization for
> scalar types is zero-initialization, so there should be no problem.
And on -that- note...
Given a class
class Foo {
int i;
}
I've found that Foo::i isn't necessary initialized to 0.
(even if Foo is on the stack not the heap).
I must include a constructor:
Foo::Foo()
: i(0)
{
}
else, someFoo.i might be just an random number.
Is this correct behaviour? (Don't take this as complaint or a request
for a bug fix... just a question).
(actually, this only happens on linux. On Solaris, i -does- seem to
0-initialize).
Thanks!
-Bob
--
Bob McWhirter Shop Foreman, Decision Scientist, Cat Juggler
Werken Digital A division of the Benjamin J. Werken & Sons Company
bob@werken.com http://www.werken.com./