220 40200 <1730cf0b-2236-49d5-a2e2-0df97b1aa24e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Should istream::read() be allowed to clobber the
 buffer beyond the file's size.
Date: Thu, 20 Sep 2018 00:50:06 -0700 (PDT)
Lines: 164
Approved: news@gmane.org
Message-ID: <1730cf0b-2236-49d5-a2e2-0df97b1aa24e@isocpp.org>
References: <21a506dd-40ae-4cae-986d-4f014de8d859@isocpp.org>
 <CAMmfjbOQo30FaJJfosjTbqroMf2yPO1=QZuq0GueJEiZX+pjrw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_276_1601830266.1537429806370"
X-Trace: blaine.gmane.org 1537429684 3987 195.159.176.226 (20 Sep 2018 07:48:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 20 Sep 2018 07:48:04 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCRIRSPDTQIRBL5CRXOQKGQEYBQKMZY@isocpp.org Thu Sep 20 09:48:00 2018
Return-path: <std-proposals+bncBCRIRSPDTQIRBL5CRXOQKGQEYBQKMZY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f71.google.com ([209.85.161.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRIRSPDTQIRBL5CRXOQKGQEYBQKMZY@isocpp.org>)
	id 1g2tgr-0000pp-O2
	for gclcip-std-proposals@m.gmane.org; Thu, 20 Sep 2018 09:47:57 +0200
Original-Received: by mail-yw1-f71.google.com with SMTP id j71-v6sf3807433ywb.22
        for <gclcip-std-proposals@m.gmane.org>; Thu, 20 Sep 2018 00:50:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        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;
        bh=fmliOj9Tq6AttGSvuIRP90a4IbglRqYFdo3X07GKEzI=;
        b=qMA9XSVDyqJM3Aqn1kPfL/NNrQ+GcGCUR2mMQIk04ryKFSHTE4JQnAfZy1fFxScPZw
         ojt5DxDSDQGAF3HO+rNWgOxyTXFPdliEVZfwNLZMjUGtmEwmiT7iCUDBL51EN7ygaXEe
         kw49iQdX92yUSEX+abIEH1zW84NtPS9ZOiczMSGQogYu5vDriqAs5hw/bI1oT2Wy+60z
         1N4XG6so8THW5YGtp8/FZ6D2BDVStkfNsBdi3xp5cTvTmAJxp2JKLd6Z8OpIg5QYzRga
         C+AmLa7GfKs6LbJnSZ72hq4fU8THrjkaTyYej0T+Oy5SOwe5lyWVxouWRxql1mQGrZ4/
         aqqA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=fmliOj9Tq6AttGSvuIRP90a4IbglRqYFdo3X07GKEzI=;
        b=VcFhNX6SV//2ZjOWlERIK+FERZufQSTdjUkVgn5LHSB3ZATs5Ja3sgHnRpFvCwoFkJ
         3a0+LdLacFm+wfTJqhtM0UY8F4QUu/radZxF3uwl0AfTfotPfbcWGrj5gSfrx87dbVJ8
         lx/rLfnNTvscyd5NjO82E1g/3ZkaojH0Aq0HfIWmxi4x9T0/gC2t521dH4Rw37bG1xLR
         vjDAYon1GuZd1t8wBhvPx+cOi6ifyLJyqhtEygOlYrQzhk52ioKW4F2mM3mVgVTe/6DE
         VktIkho0BYr+kQ8sOQ41unv9yS7hesEjCtKXqxakPnLuS7nh5nv0i4Yx+CB5AkRbUZNX
         tj6Q==
X-Gm-Message-State: APzg51B34WbpqQbr5qmjZ/8d4fJKhmOd3k6S7ZctSj/yS+svppxIMd8A
	UUbYqXPDGjL3ROvxWkDx5ryhqg==
X-Google-Smtp-Source: ANB0VdaIrpOh6lkQ5GKL++BRzmO5JIToVabYWW791QlKQF/SFFeqRHgZR8nY0Yr/KnC1/yBZQA695Q==
X-Received: by 2002:a0d:e3c4:: with SMTP id m187-v6mr4906392ywe.50.1537429808160;
        Thu, 20 Sep 2018 00:50:08 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:48d2:: with SMTP id v201-v6ls3265657ywa.35.gmail; Thu,
 20 Sep 2018 00:50:07 -0700 (PDT)
X-Received: by 2002:a81:308e:: with SMTP id w136-v6mr365975yww.0.1537429806917;
        Thu, 20 Sep 2018 00:50:06 -0700 (PDT)
In-Reply-To: <CAMmfjbOQo30FaJJfosjTbqroMf2yPO1=QZuq0GueJEiZX+pjrw@mail.gmail.com>
X-Original-Sender: bengt.gustafsson@beamways.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40200
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40200>

------=_Part_276_1601830266.1537429806370
Content-Type: multipart/alternative; 
	boundary="----=_Part_277_266712490.1537429806371"

------=_Part_277_266712490.1537429806371
Content-Type: text/plain; charset="UTF-8"

Here is the issue I posted to 
Microsoft: https://developercommunity.visualstudio.com/content/problem/326138/istreamread-clobbers-up-buffer-after-last-byte-rea.html



Den torsdag 20 september 2018 kl. 03:19:54 UTC+2 skrev Brian Bi:
>
> Can you provide an example of the code and the file that produce this 
> behaviour? The C standard seems to allow some garbage to be written for the 
> last object's value if the size of the file isn't a multiple of the object 
> size, but I'm not sure if that's what you're talking about.
>
> (C11 7.21.8.1/2)
>
> ... If a partial element is read, its value is indeterminate.
>>
> Well, that doesn't seem to be the same thing. Well, if they decided to 
call with size == buffer size and count == 1 it could be interpreted like 
that, I guess. It seems that both C and C++ standards need to be clarified 
on this point.


> On Wed, Sep 19, 2018 at 6:06 PM Bengt Gustafsson <bengt.gu...@beamways.com 
> <javascript:>> wrote:
>
>> When you do a read on an istream with a buffer larger than the file (in 
>> text mode) the MSVC was recently changed so that it may change bytes in the 
>> buffer after the file length. The same goes for the C function fread().
>>
>> I'm unsure if the standard actually allows this behaviour. Microsoft 
>> recently changed the behaviour and it broke our test programs.
>>
>> Microsoft claims this is allowed, I think it is not logical to allow it.
>>
>> Is this behaviour allowed? If it is allowed, should it be?
>>
>>
>> -- 
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/21a506dd-40ae-4cae-986d-4f014de8d859%40isocpp.org 
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/21a506dd-40ae-4cae-986d-4f014de8d859%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> *Brian Bi*
>

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1730cf0b-2236-49d5-a2e2-0df97b1aa24e%40isocpp.org.

------=_Part_277_266712490.1537429806371
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Here is the issue I posted to Microsoft:=C2=A0https://deve=
lopercommunity.visualstudio.com/content/problem/326138/istreamread-clobbers=
-up-buffer-after-last-byte-rea.html<div><br></div><div><br><br>Den torsdag =
20 september 2018 kl. 03:19:54 UTC+2 skrev Brian Bi:<blockquote class=3D"gm=
ail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc soli=
d;padding-left: 1ex;"><div dir=3D"ltr"><div dir=3D"ltr"><div>Can you provid=
e an example of the code and the file that produce this behaviour? The C st=
andard seems to allow some garbage to be written for the last object&#39;s =
value if the size of the file isn&#39;t a multiple of the object size, but =
I&#39;m not sure if that&#39;s what you&#39;re talking about.<br></div><div=
><br></div><div>(C11 <a href=3D"http://7.21.8.1/2" target=3D"_blank" rel=3D=
"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dh=
ttp%3A%2F%2F7.21.8.1%2F2\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE3_ikRO0TH=
IjrpNByasL4ve09Lnw&#39;;return true;" onclick=3D"this.href=3D&#39;http://ww=
w.google.com/url?q\x3dhttp%3A%2F%2F7.21.8.1%2F2\x26sa\x3dD\x26sntz\x3d1\x26=
usg\x3dAFQjCNE3_ikRO0THIjrpNByasL4ve09Lnw&#39;;return true;">7.21.8.1/2</a>=
)<br></div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"=
><div>... If a partial element is read, its value is indeterminate.<br></di=
v></blockquote></div></div></blockquote><div>Well, that doesn&#39;t seem to=
 be the same thing. Well, if they decided to call with size =3D=3D buffer s=
ize and count =3D=3D 1 it could be interpreted like that, I guess. It seems=
 that both C and C++ standards need to be clarified on this point.</div><di=
v><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></di=
v></blockquote></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
On Wed, Sep 19, 2018 at 6:06 PM Bengt Gustafsson &lt;<a href=3D"javascript:=
" target=3D"_blank" gdf-obfuscated-mailto=3D"oKqB8imACQAJ" rel=3D"nofollow"=
 onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"=
this.href=3D&#39;javascript:&#39;;return true;">bengt.gu...@beamways.com</a=
><wbr>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
When you do a read on an istream with a buffer larger than the file (in tex=
t mode) the MSVC was recently changed so that it may change bytes in the bu=
ffer after the file length. The same goes for the C function fread().<div><=
br></div><div>I&#39;m unsure if the standard actually allows this behaviour=
.. Microsoft recently changed the behaviour and it broke our test programs.<=
/div><div><br></div><div>Microsoft claims this is allowed, I think it is no=
t logical to allow it.</div><div><br></div><div>Is this behaviour allowed? =
If it is allowed, should it be?</div><div><br></div><div><br></div></div>

<p></p>

-- <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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
oKqB8imACQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"oKqB8imACQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/21a506dd-40ae-4cae-986d-4f014de8d859%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/21a506dd-40ae-4cae-986d-4f014de8d859%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/21a506dd-40ae-4cae-986d-4f014de8d859%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/21a506dd-40ae-4cae-<wbr>986d-=
4f014de8d859%40isocpp.org</a><wbr>.<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr"><div dir=
=3D"ltr"><div><div dir=3D"ltr"><font color=3D"#c0c0c0"><i>Brian Bi</i></fon=
t><br><div></div><div></div><div></div></div></div></div></div>
</blockquote></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1730cf0b-2236-49d5-a2e2-0df97b1aa24e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1730cf0b-2236-49d5-a2e2-0df97b1aa24e=
%40isocpp.org</a>.<br />

------=_Part_277_266712490.1537429806371--

------=_Part_276_1601830266.1537429806370--

.
