From -484548224057240250
X-Google-Thread: f78e5,e2cfdf64f67c7793
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!news.cambrium.nl!news.cambrium.nl!news.netcologne.de!nhp.netcologne.de!news.clara.net!wagner.news.clara.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: pasa@lib.hu ("Balog Pal")
Newsgroups: comp.std.c++
Subject: Re: Eliminating uninitialised variables
Date: Wed, 22 Sep 2004 17:07:53 GMT
Organization: LiB
Lines: 40
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <4150695d@andromeda.datanet.hu>
References: <memo.20040920104138.384A@brangdon.m>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1095872879 28773 158.152.254.254 (22 Sep 2004 17:07:59 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 22 Sep 2004 17:07:59 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4942.400
X-Priority: 3
X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,PRIORITY_NO_NAME 
	autolearn=no version=2.64-mulga_r1
X-MSMail-Priority: Normal
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i8MH7rsQ013027;
	Thu, 23 Sep 2004 03:07:53 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsreader: Microsoft Outlook Express 5.50.4942.400
X-Newsgroups: comp.std.c++
Xref: g2news1.google.com comp.std.c++:2823

In an old version of this thread the idea I liked the most was having

int  item = __uninitialised;
int  item(__uninitialised);

To make some variable no initialised, and perform default-init for any place
there is no initialiser.

That makes ununited stuff explicit and easy to spot and search. Also it is
backward-compatible except for performance. And not so hard to fix later.

Reusing void or anything else is a bad idea. (If you really want to save a
keyword use static instead <EG>).

>(c) Zero-initialisation is not sufficient to satisfy the class invariant.

The invariant checks shall catch that.  The main problem with noinit is it
leads to UB and in practice to nondeterministic behavior. The memory-junk
may slip through tests if it happens to satisfy the invariant for the test
run.

>Zeros are cheaper when bought in bulk, especially if they can be produced
in idle time, and especially if the O/S makes them. So it would be nice if
we could make zero-initialisation the responsibility of the memory manager
rather than the class's constructor.

You forget C++-level zero-init is not a binary zero fill.  zero and null
vlaues may come with whatever bit patterns, and they in fact do for doubles.

Paul




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



