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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Christian Franke from comment #0)
> 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.

As stated above, tThis is wrong, see src/c++98/istream-string.cc where the
specialization is defined.


> 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.

The problem is nothing to do with "C++17 compatible code" it's entirely to do
with whether the std::string template is instantiated in the current
translation unit, or only in the DLL. Cygwin apparently can't combine
definitions of static objects across DLLs, and so fails when anything is
instantiated in the current translation unit (so presumably would also happen
with Debug Mode, and if _GLIBCXX_EXTERN_TEMPLATE=0, independent of C++14 vs
C++17 modes).

Reply via email to