From: TANNHAUSER Falk <Falk.Tannhauser@crf.canon.fr>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: [GCC] C++ program calling std::getline() crashes with certain compilation flags
Date: Fri, 07 Jul 2017 11:31:00 -0000 [thread overview]
Message-ID: <a9871066e6b4419fbb75c47b56b9a374@Antiope.crf.canon.fr> (raw)
In-Reply-To: <CAPF-yOYV2NqzGJ9Faixvw92vW7s2-fDyiv40Nvh7Jy=BqjYE6g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 607 bytes --]
> Bonus points if you can reduce this testcase further, see
> https://gcc.gnu.org/wiki/A_guide_to_testcase_reduction
> for how to take the preprocessed output and automatically
> reduce it to a much smaller file.
I attach the output of
```
creduce checki.sh test_getline.i
```
where checki.sh is attached too and test_getline.i was obtained trough
```
g++ -w -std=c++98 -O0 -E -P test_getline.cxx > test_getline.i
```
Note that passing -O1 instead of -O0 doesn't change the pre-processed output,
while replacing -std=c++98 by -std=gnu++98 triggers substantial changes.
Falk
[-- Attachment #2: test_getline.i --]
[-- Type: application/octet-stream, Size: 928 bytes --]
namespace std { template < typename > class allocator; template < class > struct char_traits; template < typename b, typename = char_traits< b >, typename = allocator< b > > class basic_string; typedef basic_string< char > c; template < typename b, typename = char_traits< b > > class basic_istream; typedef basic_istream< char > d; template < typename > class allocator {}; template < typename b, typename, typename e > class basic_string { struct _Rep { b *_M_refdata(); }; struct f { f(b *g, e) : h(g) {} b *h; } i; _Rep &j() {} public: basic_string() : i(j()._M_refdata(), e()) {} }; template < typename b, typename k, typename e > basic_istream< b, k > &getline(basic_istream< b, k > &, basic_string< b, k, e > &); class ios_base { public: class Init { public: Init(); }; }; extern d cin; ios_base::Init l; }
main() { std::c a; getline(std::cin, a); }
[-- Attachment #3: checki.sh --]
[-- Type: application/octet-stream, Size: 245 bytes --]
g++ -w -std=c++98 -O0 test_getline.i -o test_getline && echo a | ./test_getline
if ! test "$?" = "0" ; then exit 1 ; fi
g++ -w -std=c++98 -O1 test_getline.i -o test_getline && echo a | ./test_getline
if test "$?" = "0" ; then exit 1 ; fi
exit 0
[-- Attachment #4: Type: text/plain, Size: 219 bytes --]
--
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 prev parent reply other threads:[~2017-07-07 11:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 13:07 TANNHAUSER Falk
2017-07-06 14:21 ` Dan Kegel
2017-07-07 11:31 ` TANNHAUSER Falk [this message]
2017-07-13 12:01 ` TANNHAUSER Falk
2017-07-06 14:53 ` Masamichi Hosoda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9871066e6b4419fbb75c47b56b9a374@Antiope.crf.canon.fr \
--to=falk.tannhauser@crf.canon.fr \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).