https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86138

            Bug ID: 86138
           Summary: C++17: getline(istream, string) crashes on Cygwin
                    because incompatible C++14 function is called
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: franke at computer dot org
  Target Milestone: ---

The function std::getline(istream &, string &, char) crashes if build with
Cygwin gcc-g++-7.3.0-2 and -std=gnu++17 enabled.

This is because there is a bogus prototype specialization in basic_string.h:

  template<>
    basic_istream<char>&
    getline(basic_istream<char>& __in, basic_string<char>& __str,
    char __delim);

There is no implementation for this specialization. This has apparently the
same effect as the 'extern template' which is disabled for C++17 in
basic_string.tcc:

#if _GLIBCXX_EXTERN_TEMPLATE > 0 && __cplusplus <= 201402L
  ...
  extern template
    basic_istream<char>&
    getline(basic_istream<char>&, string&, char);
  ...
#endif

As a consequence, no C++17 compatible code for this getline() is generated and
the old getline() from cygstdc++-6.dll is called instead.

AFAICS the above still holds for current SVN trunk release 261563.

For a testcase and a proposed patch see:
https://cygwin.com/ml/cygwin/2018-06/msg00125.html

Reply via email to