delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/07/06/10:53:34

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:to:subject:from:in-reply-to
:references:mime-version:content-type:content-transfer-encoding;
q=dns; s=default; b=QZxrmv61koVmEkGyteXgmP0WX9t8+5seQePiOJk0iI5
AkieTLpmwPmLy0LwuxlnVgKjNlaXJg/5jiciXhc6XqQyM70zLDpSHPmmDQLsRWL8
dQXivRY3wWaBwQFHIjxBYC0vp793tyRod03IyPjde/8UdF5SY0oSDWbeCpfYMH90
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:message-id:to:subject:from:in-reply-to
:references:mime-version:content-type:content-transfer-encoding;
s=default; bh=TLA7Z9e2wN84Sudd9GmyKuu46sI=; b=wDU65OPrIk8Fw1Uid
Mg44b7x8Ye2SLYwehoL51t99ghkOAk2B1jz/mlYBKbXR65SuTc+vVEQgPchq4Vdv
4a2FdN5bdzAeXmyv6cHKU3clUscMJoOP9FrRlG53u8GjLq3TTinVSTOk8A/LU4Yh
mEUNVthL5R7vQ0ejeCMIQy2lXg=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*c:Mixed, H*c:NHxt, H*c:PHrt, H*c:HHH
X-HELO: msa01y.plala.or.jp
Date: Thu, 06 Jul 2017 23:53:07 +0900 (JST)
Message-Id: <20170706.235307.636695868819506563.trueroad@trueroad.jp>
To: cygwin AT cygwin DOT com
Subject: Re: [GCC] C++ program calling std::getline() crashes with certain compilation flags
From: Masamichi Hosoda <trueroad AT trueroad DOT jp>
In-Reply-To: <80757ab8baa6434a8c56104c0ebfe803@Antiope.crf.canon.fr>
References: <80757ab8baa6434a8c56104c0ebfe803 AT Antiope DOT crf DOT canon DOT fr>
Mime-Version: 1.0
X-VirusScan: Outbound; msa01m; Thu, 6 Jul 2017 23:53:06 +0900

----Next_Part(Thu_Jul__6_23_53_07_2017_497)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

> The following C++ program crashes when compiled with GCC (both 5.4 and 6.3) under Cygwin, when compiled with both an optimization level higher than -O0 (i.e. -O1, -O2 or -O3) and the C++ standard set to -std=c++nn (for any supported nn, i.e. 98, 03, 11, 14 or 17):
> ```
> #include <iostream>
> #include <string>
> int main()
> {
>     std::string s;
>     std::getline(std::cin, s);
>     std::cout << "You entered \"" << s << "\".\n";
>     return 0;
> }
> ```
> On the other hand, when compiled with -std=gnu++nn or -O0, the program executes normally. For details, run the attached Bash script test_getline.sh, which produces the output contained in the attached file test_getline_Cygwin.txt . No similar problem shows with GCC under Linux.
> It looks similar to the problem reported in https://cygwin.com/ml/cygwin/2017-07/msg00088.html which appears to be circumvented by passing -std=gnu++11 instead of -std=c++11.

I've tried it with both cygwin-devel-2.8.0-1 and cygwin-devel-2.8.1-1.
With cygwin-devel-2.8.1-1, reproduced.
With cygwin-devel-2.8.0-1, there is no problem.

I've attached the script that I used and the results.

----Next_Part(Thu_Jul__6_23_53_07_2017_497)--
Content-Type: Application/Octet-Stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test_getline.sh"

Y2F0IDw8RU9GID4gdGVzdF9nZXRsaW5lLmN4eAovLyBMZXQncyBzZWUgaWYg
aXQgd29ya3MuLi4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3Ry
aW5nPgppbnQgbWFpbigpCnsKICAgIHN0ZDo6c3RyaW5nIHM7CiAgICBzdGQ6
OmdldGxpbmUoc3RkOjpjaW4sIHMpOwogICAgc3RkOjpjb3V0IDw8ICJZb3Ug
ZW50ZXJlZCBcIiIgPDwgcyA8PCAiXCIuXG4iOwogICAgcmV0dXJuIDA7Cn0K
RU9GCgp1bmFtZSAtYQphcHQtY3lnIHNob3cgfCBncmVwICJjeWd3aW4iCmcr
KyAtLXZlcnNpb24KCmZvciBzdGQgaW4gYysrOTggYysrMDMgYysrMTEgYysr
MTQgYysrMTcgZ251Kys5OCBnbnUrKzAzIGdudSsrMTEgZ251KysxNCBnbnUr
KzE3IDsgZG8KICAgIGZvciBvcHQgaW4gMCAxIDIgMyA7IGRvCiAgICAgICAg
ZWNobyAtbiAiIyMjIC1zdGQ9JHtzdGR9IC1PJHtvcHR9ICMjIzogIgogICAg
ICAgIGcrKyAtV2FsbCAtV2V4dHJhIC1zdGQ9JHtzdGR9IC1PJHtvcHR9IHRl
c3RfZ2V0bGluZS5jeHggLW8gdGVzdF9nZXRsaW5lICYmCiAgICAgICAgICAg
IC4vdGVzdF9nZXRsaW5lIDwgdGVzdF9nZXRsaW5lLmN4eAogICAgZG9uZQpk
b25lIDI+JjEgfCBzZWQgJ3N8IFx7NSxcfXwgfGcnCg==

----Next_Part(Thu_Jul__6_23_53_07_2017_497)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="test_getline_cygwin-devel-2.8.0-1.txt"

CYGWIN_NT-10.0 Z87EXTREAM4 2.8.1(0.312/5/3) 2017-07-03 14:11 x86_64 Cygwin
base-cygwin                                   3.8-1
cygwin                                        2.8.1-1
cygwin-debuginfo                              2.8.1-1
cygwin-devel                                  2.8.0-1
g++ (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

### -std=c++98 -O0 ###: You entered "// Let's see if it works...".
### -std=c++98 -O1 ###: You entered "// Let's see if it works...".
### -std=c++98 -O2 ###: You entered "// Let's see if it works...".
### -std=c++98 -O3 ###: You entered "// Let's see if it works...".
### -std=c++03 -O0 ###: You entered "// Let's see if it works...".
### -std=c++03 -O1 ###: You entered "// Let's see if it works...".
### -std=c++03 -O2 ###: You entered "// Let's see if it works...".
### -std=c++03 -O3 ###: You entered "// Let's see if it works...".
### -std=c++11 -O0 ###: You entered "// Let's see if it works...".
### -std=c++11 -O1 ###: You entered "// Let's see if it works...".
### -std=c++11 -O2 ###: You entered "// Let's see if it works...".
### -std=c++11 -O3 ###: You entered "// Let's see if it works...".
### -std=c++14 -O0 ###: You entered "// Let's see if it works...".
### -std=c++14 -O1 ###: You entered "// Let's see if it works...".
### -std=c++14 -O2 ###: You entered "// Let's see if it works...".
### -std=c++14 -O3 ###: You entered "// Let's see if it works...".
### -std=c++17 -O0 ###: You entered "// Let's see if it works...".
### -std=c++17 -O1 ###: You entered "// Let's see if it works...".
### -std=c++17 -O2 ###: You entered "// Let's see if it works...".
### -std=c++17 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O3 ###: You entered "// Let's see if it works...".

----Next_Part(Thu_Jul__6_23_53_07_2017_497)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="test_getline_cygwin-devel-2.8.1-1.txt"

CYGWIN_NT-10.0 Z87EXTREAM4 2.8.1(0.312/5/3) 2017-07-03 14:11 x86_64 Cygwin
base-cygwin                                   3.8-1
cygwin                                        2.8.1-1
cygwin-debuginfo                              2.8.1-1
cygwin-devel                                  2.8.1-1
g++ (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

### -std=c++98 -O0 ###: You entered "// Let's see if it works...".
### -std=c++98 -O1 ###: ./test_getline.sh: line 19: 20748 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++98 -O2 ###: ./test_getline.sh: line 19: 25148 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++98 -O3 ###: ./test_getline.sh: line 19:  8540 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++03 -O0 ###: You entered "// Let's see if it works...".
### -std=c++03 -O1 ###: ./test_getline.sh: line 19: 16156 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++03 -O2 ###: ./test_getline.sh: line 19: 12172 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++03 -O3 ###: ./test_getline.sh: line 19:   160 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++11 -O0 ###: You entered "// Let's see if it works...".
### -std=c++11 -O1 ###: ./test_getline.sh: line 19: 24840 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++11 -O2 ###: ./test_getline.sh: line 19: 12008 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++11 -O3 ###: ./test_getline.sh: line 19:  8140 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++14 -O0 ###: You entered "// Let's see if it works...".
### -std=c++14 -O1 ###: ./test_getline.sh: line 19:  7376 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++14 -O2 ###: ./test_getline.sh: line 19: 18080 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++14 -O3 ###: ./test_getline.sh: line 19: 22692 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++17 -O0 ###: You entered "// Let's see if it works...".
### -std=c++17 -O1 ###: ./test_getline.sh: line 19:  5796 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++17 -O2 ###: ./test_getline.sh: line 19: 24008 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=c++17 -O3 ###: ./test_getline.sh: line 19:  2844 Aborted (core dumped) ./test_getline < test_getline.cxx
### -std=gnu++98 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++98 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++03 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++11 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++14 -O3 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O0 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O1 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O2 ###: You entered "// Let's see if it works...".
### -std=gnu++17 -O3 ###: You entered "// Let's see if it works...".


----Next_Part(Thu_Jul__6_23_53_07_2017_497)--
Content-Type: text/plain; charset=us-ascii


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
----Next_Part(Thu_Jul__6_23_53_07_2017_497)----

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019