This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/86138] C++17: getline(istream, string) crashes on Cygwin because incompatible C++14 function is called


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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Only the std::string and std::wstring instantiations are problematic for C++17.
This should be a better fix, i.e. allow the getline instantiations to be used
even in C++17 mode:

--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -1597,8 +1597,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

   // Inhibit implicit instantiations for required instantiations,
   // which are defined via explicit instantiations elsewhere.
-#if _GLIBCXX_EXTERN_TEMPLATE > 0 && __cplusplus <= 201402L
+#if _GLIBCXX_EXTERN_TEMPLATE > 0
+#if __cplusplus <= 201402L
   extern template class basic_string<char>;
+#endif
   extern template
     basic_istream<char>&
     operator>>(basic_istream<char>&, string&);
@@ -1613,7 +1615,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     getline(basic_istream<char>&, string&);

 #ifdef _GLIBCXX_USE_WCHAR_T
+#if __cplusplus <= 201402L
   extern template class basic_string<wchar_t>;
+#endif
   extern template
     basic_istream<wchar_t>&
     operator>>(basic_istream<wchar_t>&, wstring&);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]