220 11978 <8021febe-7c98-400e-8167-3d6dbb695a12@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Controversy and debate: Uninitialized variables
 by default is a bug
Date: Sun, 20 Jul 2014 21:00:51 -0700 (PDT)
Lines: 116
Approved: news@gmane.org
Message-ID: <8021febe-7c98-400e-8167-3d6dbb695a12@isocpp.org>
References: <60caa4ef-b32d-40fe-97b6-8918fbb2bd51@isocpp.org> <CAGg_6+Ossg1SPRDSw5qnHR4ZW8NrgT4W8z7uHLAgD7mvfh-wtQ@mail.gmail.com> <ec6e4a5c-c6c9-4921-ac4c-38373fc219ae@isocpp.org> <20140620202026.GA29898@bacon.lysator.liu.se>
 <0329E32D-0EC2-4BE0-85D0-492A4CF22B0B@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1726_159171850.1405915251688"
X-Trace: ger.gmane.org 1405915264 10404 80.91.229.3 (21 Jul 2014 04:01:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 21 Jul 2014 04:01:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRB5FAWKPAKGQEA2JQV2A@isocpp.org Mon Jul 21 06:00:57 2014
Return-path: <std-proposals+bncBDELF54RTIGRB5FAWKPAKGQEA2JQV2A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wg0-f70.google.com ([74.125.82.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRB5FAWKPAKGQEA2JQV2A@isocpp.org>)
	id 1X94mV-0007cZ-6B
	for gclcip-std-proposals@m.gmane.org; Mon, 21 Jul 2014 06:00:55 +0200
Original-Received: by mail-wg0-f70.google.com with SMTP id l18sf4153683wgh.1
        for <gclcip-std-proposals@m.gmane.org>; Sun, 20 Jul 2014 21:00:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=VjMGjXeDpsN4gfLEXLQl1xvguWPm0VjmqRILqd9zwjk=;
        b=yZwjOQVJR0fTpCZvqD5ERRPwgQ95CsSHO25HolK2oEPzw0Z3J3jxfrVNBwsW8oaNDt
         iP+c1dsA50xR6oZFCCXmoobzLIsKNrqLiFyoo+g0Uct4jEDB4zL8ZhRzp+op8rXg+Knc
         sOT/fgHXyy43bVSYJSDox8Xzn3tww52XbiveEmjhnOQIuBy69Y01nszpNdpdgr3WosbU
         qNZJunypJXiJUKIMqvRwsX2qbiH/HJUCsi3tPHcPrdYIgmtOyYL0zcZ7iZLi0hf3nxEH
         vka7arzQGP1ScNHcHMHahofWpkSxIR1QNBBddTbXNApBcYhaD62YjYdp63qdUpe7iNVA
         whRQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=VjMGjXeDpsN4gfLEXLQl1xvguWPm0VjmqRILqd9zwjk=;
        b=XGYUcar3AkskkBTOlwZMTjfmt+enNRzYNoYBJl3Jhvtcu/S95u8MH3xfCeYsjR48bY
         FL2Nm5t7qZ0JFuKt4skaZ8ZE8NAkmuN50tu0H08gbl8VKg6QPJzKN+AtAusVeeNnFsBj
         LW/Y2CHs/3VH2KrkdBgPkhKfUNypfwuEs/P3tIPqsUPUph7Y8B2PeeQz+R72Ykhs4X/f
         mGcEI9BE5AQUDDvvvyiU9sRAMeK0r615PFSH3SCavl155ZdvSPuxvt5vzeOVr7X1OT4L
         4MOeONlZkKpfToUJ1xAeUENyo38GrFOIOzSflC3nbRnJZu2bpoB6WaN1NUyMQzatitl2
         /bJw==
X-Gm-Message-State: ALoCoQkQB5vAs/KtYf1u1lweIBOhHLXuAO7efYM5bsDd7Qzj5W/xUSebsL5nt3fHJfgcIPKabCw4
X-Received: by 10.112.0.162 with SMTP id 2mr1650194lbf.3.1405915254716;
        Sun, 20 Jul 2014 21:00:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.95.193 with SMTP id i59ls1755980qge.20.gmail; Sun, 20 Jul
 2014 21:00:52 -0700 (PDT)
X-Received: by 10.140.30.52 with SMTP id c49mr9933qgc.7.1405915252417;
        Sun, 20 Jul 2014 21:00:52 -0700 (PDT)
In-Reply-To: <0329E32D-0EC2-4BE0-85D0-492A4CF22B0B@gmail.com>
X-Original-Sender: fmatthew5876@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:11978
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11978>

------=_Part_1726_159171850.1405915251688
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Why not just a std::noinit<T> wrapper?

std::vector<std::noinit<int>>; //Does not initialize contents on=20
construction

Then the non-initialization is documented and enforced by the type system.=
=20
Another option is a simple std::allocator implementation.


On Monday, June 30, 2014 11:52:45 AM UTC-4, David Krauss wrote:
>
>
> On 2014=E2=80=9306=E2=80=9321, at 4:20 AM, Magnus Fromreide <ma...@lysato=
r.liu.se=20
> <javascript:>> wrote:=20
>
> > That would probably require some way to detect=20
> explicit-non-initialization=20
> > in order to support=20
> >=20
> > std::vector<int> v(MEGABYTE, __no_init__); // a megabyte vector with=20
> >                                           // unspecified content=20
> >=20
> > which seems like a natural extension if explicit non-initialization is=
=20
> > added to the language.=20
>
>
> __no_init__ (or uninitialized, or whatever) could be like nullptr, a sole=
=20
> value of its type.=20
>
> A library-only solution (with conversion functions) would even be=20
> workable, but for the fact that you cannot copy an uninitialized object.=
=20
>
> It sounds like a nice core language extension.=20
>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_1726_159171850.1405915251688
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Why not just a std::noinit&lt;T&gt; wrapper?<div><br></div=
><div>std::vector&lt;std::noinit&lt;int&gt;&gt;; //Does not initialize cont=
ents on construction</div><div><br></div><div>Then the non-initialization i=
s documented and enforced by the type system. Another option is a simple st=
d::allocator implementation.</div><div><br></div><div><br>On Monday, June 3=
0, 2014 11:52:45 AM UTC-4, David Krauss wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;">
<br>On 2014=E2=80=9306=E2=80=9321, at 4:20 AM, Magnus Fromreide &lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"6wyCFwRYUS0J" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">ma...@lysator.liu.se</a>&gt; wrote:
<br>
<br>&gt; That would probably require some way to detect explicit-non-initia=
lization
<br>&gt; in order to support
<br>&gt;=20
<br>&gt; std::vector&lt;int&gt; v(MEGABYTE, __no_init__); // a megabyte vec=
tor with
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; // unspecified content
<br>&gt;=20
<br>&gt; which seems like a natural extension if explicit non-initializatio=
n is
<br>&gt; added to the language.
<br>
<br>
<br>__no_init__ (or uninitialized, or whatever) could be like nullptr, a so=
le value of its type.
<br>
<br>A library-only solution (with conversion functions) would even be worka=
ble, but for the fact that you cannot copy an uninitialized object.
<br>
<br>It sounds like a nice core language extension.
<br>
<br></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1726_159171850.1405915251688--

.
