From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36361 invoked by alias); 12 Jun 2018 17:12:00 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 36322 invoked by uid 89); 12 Jun 2018 17:12:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:encrypted, H*r:sk:mailout, christian X-HELO: mailout12.t-online.de Received: from mailout12.t-online.de (HELO mailout12.t-online.de) (194.25.134.22) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Jun 2018 17:11:57 +0000 Received: from fwd07.aul.t-online.de (fwd07.aul.t-online.de [172.20.27.150]) by mailout12.t-online.de (Postfix) with SMTP id 5AAF541F2152 for ; Tue, 12 Jun 2018 19:11:55 +0200 (CEST) Received: from [192.168.2.101] (JbVts4ZeohnCafkD5E8w1677cY-fyH8-GsYr5ymUUS0N1i3r-tNRMt3ClQV6BKsgco@[87.187.36.100]) by fwd07.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1fSmpi-1MJgmG0; Tue, 12 Jun 2018 19:11:50 +0200 From: Christian Franke Subject: Re: GCC 7.3.0 -std=gnu++17 failed to getline() from std::ifstream To: cygwin@cygwin.com References: Message-ID: <0725bdbd-0411-138a-7ea9-d6395e3256e3@t-online.de> Date: Tue, 12 Jun 2018 18:02:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0 SeaMonkey/2.50 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------2919FF0A3B0A158CCF9BFF23" X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00127.txt.bz2 --------------2919FF0A3B0A158CCF9BFF23 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1593 Ivan Shynkarenka wrote: > I use x64 bit Cygwin and it failed in my home, work and Appveyor. I add > cygcheck.out with my environment. > > I'm sorry about misspell prefix space in my prev example. Please try the > following one: > > #include > #include > > int main(int argc, char** argv) > { > std::string line; > std::ifstream stream("test.cpp"); > while (getline(stream, line)) > std::cout << line << std::endl; > return 0; > } > > g++ -std=gnu++17 test.cpp Could reproduce this with 32 and 64 bit Cygwin g++ 7.3.0 A comparison of preprocessor (-E) outputs shows that the "extern template" declarations for getline() are only visible for C++ <= 14. These are guarded by "__cplusplus <= 1402" in basic_string.tcc. This should tell the compiler to generate new code for getline() if C++17 is enabled instead of calling the (now incompatible) function in cygstdc++-6.dll. A comparison of assembly (-S) outputs shows that this does not work: If C++17 is enabled, the compiler correctly generates local code for getline(istream &, string &) but this code calls an external getline(istream &, string &, char). Then the linker generates a call to this getline() in cygstdc++-6.dll. This is because there is a bogus prototype specialization for getline(istream &, string &, char) in basic_string.h but no corresponding implementation in basic_string.tcc. This has apparently an equivalent effect as 'extern template'. The attached patch for /usr/lib/gcc/*-pc-cygwin/7.3.0/include/c++/bits/basic_string.h fixes this. Christian --------------2919FF0A3B0A158CCF9BFF23 Content-Type: text/plain; charset=UTF-8; name="basic_string.h.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="basic_string.h.patch" Content-length: 749 LS0tIGJhc2ljX3N0cmluZy5oLm9yaWcJMjAxOC0wNS0wMyAwNjoyMjo0Ni4w MDAwMDAwMDAgKzAyMDAKKysrIGJhc2ljX3N0cmluZy5oCTIwMTgtMDYtMTIg MTU6NTY6MDMuMjE1MTc5MzAwICswMjAwCkBAIC02MzI5LDE4ICs2MzI5LDYg QEAKICAgICB7IHJldHVybiBzdGQ6OmdldGxpbmUoX19pcywgX19zdHIpOyB9 CiAjZW5kaWYKIAotICB0ZW1wbGF0ZTw+Ci0gICAgYmFzaWNfaXN0cmVhbTxj aGFyPiYKLSAgICBnZXRsaW5lKGJhc2ljX2lzdHJlYW08Y2hhcj4mIF9faW4s IGJhc2ljX3N0cmluZzxjaGFyPiYgX19zdHIsCi0JICAgIGNoYXIgX19kZWxp bSk7Ci0KLSNpZmRlZiBfR0xJQkNYWF9VU0VfV0NIQVJfVAotICB0ZW1wbGF0 ZTw+Ci0gICAgYmFzaWNfaXN0cmVhbTx3Y2hhcl90PiYKLSAgICBnZXRsaW5l KGJhc2ljX2lzdHJlYW08d2NoYXJfdD4mIF9faW4sIGJhc2ljX3N0cmluZzx3 Y2hhcl90PiYgX19zdHIsCi0JICAgIHdjaGFyX3QgX19kZWxpbSk7Ci0jZW5k aWYgIAotCiBfR0xJQkNYWF9FTkRfTkFNRVNQQUNFX1ZFUlNJT04KIH0gLy8g bmFtZXNwYWNlCiAK --------------2919FF0A3B0A158CCF9BFF23 Content-Type: text/plain; charset=us-ascii Content-length: 219 -- 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 --------------2919FF0A3B0A158CCF9BFF23--