220 11485 <0c70b26d-9af9-498d-b27f-37cf7afe9655@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: Tue, 17 Jun 2014 09:07:30 -0700 (PDT)
Lines: 171
Approved: news@gmane.org
Message-ID: <0c70b26d-9af9-498d-b27f-37cf7afe9655@isocpp.org>
References: <60caa4ef-b32d-40fe-97b6-8918fbb2bd51@isocpp.org>
 <CAFk2RUYuHAmfzOR8CB_f6kgwPSnd7=sHP=qDy3pMO98cfbqcLA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_285_17506883.1403021250950"
X-Trace: ger.gmane.org 1403021261 13518 80.91.229.3 (17 Jun 2014 16:07:41 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 17 Jun 2014 16:07:41 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRBRGPQGOQKGQE2YDLDKQ@isocpp.org Tue Jun 17 18:07:34 2014
Return-path: <std-proposals+bncBDELF54RTIGRBRGPQGOQKGQE2YDLDKQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pb0-f72.google.com ([209.85.160.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRBRGPQGOQKGQE2YDLDKQ@isocpp.org>)
	id 1Wwvv3-0003hz-UW
	for gclcip-std-proposals@m.gmane.org; Tue, 17 Jun 2014 18:07:34 +0200
Original-Received: by mail-pb0-f72.google.com with SMTP id ma3sf26286427pbc.11
        for <gclcip-std-proposals@m.gmane.org>; Tue, 17 Jun 2014 09:07:32 -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=/ykRh4wUoK5YTbNk6KCyo10tT3qUBSB0QRHS19oVyWI=;
        b=vLj0jUluTPab2ed+0v050ghsoTJ4m4raotWuBHYGu7+oEHHu9ZnF+FSyKfQlgtHghV
         vsGO1RCscuWpDGynJ+0dzYHZL4FpOfxgLP4SkwwnClIbHcTKOxZ7vWjv8LljvRAV/DvB
         bbm5dMazzKqcfJDg3iEmhLqD061GxgLNpJiOd9kY1G2NjXCuqa4OreIxgGxV4q5l7zp5
         hxECWzrCyS4nIRS6ITb8pBuGXydbVI966y4jWjkoMXTSY+9zSTaHrOs8MG0k+fNCbfmY
         veRxvCuI0Qz8ZLXD9ZEMpU1wA2ueCev8xENrUtOEuG2a6b+x7HSxOwsmaPTOEJ+zAU+W
         xSEQ==
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=/ykRh4wUoK5YTbNk6KCyo10tT3qUBSB0QRHS19oVyWI=;
        b=lhowHrI4kyOoO28OkgvnUCZs/ZMVzCyK8G3wIs2GON3YJHV6SDilhRL8QUO0nCbyAm
         uAGH6U5odyTId5WDHtR/5F1wzDH18r46jFkC3OIAMdO8WLyn2wnTvezLoUzienUTyLTa
         pyTICpg/u03g10TGhBXbi8+mYt8bwQOFYgm3+kpmjD96hEy9ABJ4CFZYDOa+wTFe4jKP
         KMJCPVaU77jYT7cUlVm+hBfdF6NGLuk6JfNIbIFqYk9MRTkk2JWJbrhauUEJZVHFqASM
         Z7ToSjXv2LABzemlMsa4PQ1sY7gbytUVWZFl8JKjBTKkl7/c9DYvuJZwYCoH3mRthSz/
         ekzg==
X-Gm-Message-State: ALoCoQn3LshIjN/jXxHofuCjrXGEqlUObX4/ObZYtJf10gXwm3sCXX39VhBNfGCqLZuiBwE8T9UG
X-Received: by 10.67.4.202 with SMTP id cg10mr1004877pad.42.1403021252827;
        Tue, 17 Jun 2014 09:07:32 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.37.211 with SMTP id r77ls1781097qgr.10.gmail; Tue, 17 Jun
 2014 09:07:32 -0700 (PDT)
X-Received: by 10.140.48.101 with SMTP id n92mr64693qga.15.1403021252237;
        Tue, 17 Jun 2014 09:07:32 -0700 (PDT)
In-Reply-To: <CAFk2RUYuHAmfzOR8CB_f6kgwPSnd7=sHP=qDy3pMO98cfbqcLA@mail.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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:11485
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11485>

------=_Part_285_17506883.1403021250950
Content-Type: text/plain; charset=UTF-8



On Tuesday, June 17, 2014 11:58:11 AM UTC-4, Ville Voutilainen wrote:
>
> On 17 June 2014 18:49, Matthew Fioravante <fmatth...@gmail.com 
> <javascript:>> wrote: 
> > This is going to be controversial, but lets get into it. 
> > 
> > The fact that `int x;` creates an uninitialized integer instead of a 
> default 
> > initialized one is completely wrong. I consider it a major defect in the 
> > language, a bug in the standard. 
>
> Well, it's not a bug by any definition that the committee uses, since we 
> know 
> about it, and it's 100% intentional. 
>
> > Please now, convince if you can why this is a bad idea. Why should we 
>
>
> char buf[MEGABYTE]; 
>

Arrays are not an exception.

If buf[MEGABYTE] is a global, its already initialized to 0.

If its a class member or on the stack, you can say

char buf[MEGABYTE] = void; 

to skip initialization. Otherwise it gets filled with 0s.


> buf[HERE] = something; 
> buf[THERE] = something_else; 
>
> According to what you propose, the mere definition of buf would go 
> through all of that 
> megabyte and zero-initialize the chars. 
>
> Or perhaps you meant that arrays are an exception? What about 
>
> struct X { char buf[MEGABYTE]; }; 
>
> X x; 
>
> Is this also an exception to the rule? 
>

Possibilities here:

struct X { char buf[MEGABYTE] = void }; //All default constructed objects 
of type X will have uninitialized buffers
X x; //< buf is not initialized

//OR
struct X { char buf[MEGABYTE]; };
X x = void; //<-This particular x will not initialize its members by 
default (Same as X x; now)
 

>
> How many performance expectations of how much existing code do you think 
> this 
> change would break? 
>

We would need to study this to find out. 

>
> The committee's answer to this question has always been "too many, too 
> much", and 
> I don't see that changing. 
>

-- 

--- 
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 email 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-proposals/.

------=_Part_285_17506883.1403021250950
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, June 17, 2014 11:58:11 AM UTC-4, Ville=
 Voutilainen wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 17 June =
2014 18:49, Matthew Fioravante &lt;<a href=3D"javascript:" target=3D"_blank=
" gdf-obfuscated-mailto=3D"ecsSg8VB8ZkJ" onmousedown=3D"this.href=3D'javasc=
ript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">fma=
tth...@gmail.com</a>&gt; wrote:
<br>&gt; This is going to be controversial, but lets get into it.
<br>&gt;
<br>&gt; The fact that `int x;` creates an uninitialized integer instead of=
 a default
<br>&gt; initialized one is completely wrong. I consider it a major defect =
in the
<br>&gt; language, a bug in the standard.
<br>
<br>Well, it's not a bug by any definition that the committee uses, since w=
e know
<br>about it, and it's 100% intentional.
<br>
<br>&gt; Please now, convince if you can why this is a bad idea. Why should=
 we
<br>
<br>
<br>char buf[MEGABYTE];
<br></blockquote><div><br>Arrays are not an exception.<br><br>If buf[MEGABY=
TE] is a global, its already initialized to 0.<br><br>If its a class member=
 or on the stack, you can say<br><br>char buf[MEGABYTE] =3D void; <br><br>t=
o skip initialization. Otherwise it gets filled with 0s.<br><br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;">
<br>buf[HERE] =3D something;
<br>buf[THERE] =3D something_else;
<br>
<br>According to what you propose, the mere definition of buf would go
<br>through all of that
<br>megabyte and zero-initialize the chars.
<br>
<br>Or perhaps you meant that arrays are an exception? What about
<br>
<br>struct X { char buf[MEGABYTE]; };
<br>
<br>X x;
<br>
<br>Is this also an exception to the rule?
<br></blockquote><div><br>Possibilities here:<br><br>struct X { char buf[ME=
GABYTE] =3D void }; //All default constructed objects of type X will have u=
ninitialized buffers<br>X x; //&lt; buf is not initialized<br><br>//OR<br>s=
truct X { char buf[MEGABYTE]; };<br>X x =3D void; //&lt;-This particular x =
will not initialize its members by default (Same as X x; now)<br>&nbsp;<br>=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>How many performance expectations of how much existing code do you thin=
k this
<br>change would break?
<br></blockquote><div><br>We would need to study this to find out. <br></di=
v><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;">
<br>The committee's answer to this question has always been "too many, too
<br>much", and
<br>I don't see that changing.
<br></blockquote></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_285_17506883.1403021250950--

.
