[Bug libstdc++/86138] C++17: getline(istream, string) crashes on Cygwin because incompatible C++14 function is called
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 21 11:28:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86138
--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Christian Franke from comment #13)
> This patch prevents duplicate _S_empty_rep_storage[] even on Cygwin (char
> only, wchar_t missing). Testcase works as expected then:
>
> --- basic_string.tcc.orig 2018-05-03 06:22:46.000000000 +0200
> +++ basic_string.tcc 2018-06-21 13:00:03.370070700 +0200
> @@ -1597,7 +1597,8 @@
>
> // 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>;
> extern template
> basic_istream<char>&
> @@ -1627,6 +1628,12 @@
> basic_istream<wchar_t>&
> getline(basic_istream<wchar_t>&, wstring&);
> #endif
> +
> +#else
> + extern template
> + basic_string<char>::size_type
> + basic_string<char>::_Rep::_S_empty_rep_storage[];
> +#endif
> #endif
This will only work for the old ABI, if you compile with
_GLIBCXX_USE_CXX11_ABI=1 those declarations are invalid.
But I like the basic idea, that will ensure that the part that must be unique
is unique, but the member functions that are C++17-only will still be
implicitly instantiated as needed.
I'll prepare a complete and correct version of this patch.
More information about the Gcc-bugs
mailing list