|
|
870cb9 |
2018-06-22 Jonathan Wakely <jwakely@redhat.com>
|
|
|
870cb9 |
|
|
|
870cb9 |
PR libstdc++/86138
|
|
|
870cb9 |
* include/bits/basic_string.tcc:
|
|
|
870cb9 |
[__cplusplus > 201402 && !_GLIBCXX_USE_CXX11_ABI]
|
|
|
870cb9 |
(basic_string<char>::_Rep::_S_empty_rep_storage)
|
|
|
870cb9 |
(basic_string<wchar_t>::_Rep::_S_empty_rep_storage): Add explicit
|
|
|
870cb9 |
instantiation declarations.
|
|
|
870cb9 |
[__cplusplus > 201402] (operator>>, operator<<, getline): Re-enable
|
|
|
870cb9 |
explicit instantiation declarations.
|
|
|
870cb9 |
* testsuite/21_strings/basic_string/cons/char/86138.cc: New.
|
|
|
870cb9 |
* testsuite/21_strings/basic_string/cons/wchar_t/86138.cc: New.
|
|
|
870cb9 |
|
|
|
870cb9 |
--- libstdc++-v3/include/bits/basic_string.tcc
|
|
|
870cb9 |
+++ libstdc++-v3/include/bits/basic_string.tcc
|
|
|
870cb9 |
@@ -1597,8 +1597,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
870cb9 |
|
|
|
870cb9 |
// Inhibit implicit instantiations for required instantiations,
|
|
|
870cb9 |
// which are defined via explicit instantiations elsewhere.
|
|
|
870cb9 |
-#if _GLIBCXX_EXTERN_TEMPLATE > 0 && __cplusplus <= 201402L
|
|
|
870cb9 |
+#if _GLIBCXX_EXTERN_TEMPLATE > 0
|
|
|
870cb9 |
+ // The explicit instantiations definitions in src/c++11/string-inst.cc
|
|
|
870cb9 |
+ // are compiled as C++14, so the new C++17 members aren't instantiated.
|
|
|
870cb9 |
+ // Until those definitions are compiled as C++17 suppress the declaration,
|
|
|
870cb9 |
+ // so C++17 code will implicitly instantiate std::string and std::wstring
|
|
|
870cb9 |
+ // as needed.
|
|
|
870cb9 |
+# if __cplusplus <= 201402L
|
|
|
870cb9 |
extern template class basic_string<char>;
|
|
|
870cb9 |
+# elif ! _GLIBCXX_USE_CXX11_ABI
|
|
|
870cb9 |
+ // Still need to prevent implicit instantiation of the COW empty rep,
|
|
|
870cb9 |
+ // to ensure the definition in libstdc++.so is unique (PR 86138).
|
|
|
870cb9 |
+ extern template basic_string<char>::size_type
|
|
|
870cb9 |
+ basic_string<char>::_Rep::_S_empty_rep_storage[];
|
|
|
870cb9 |
+# endif
|
|
|
870cb9 |
+
|
|
|
870cb9 |
extern template
|
|
|
870cb9 |
basic_istream<char>&
|
|
|
870cb9 |
operator>>(basic_istream<char>&, string&);
|
|
|
870cb9 |
@@ -1613,7 +1626,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
870cb9 |
getline(basic_istream<char>&, string&);
|
|
|
870cb9 |
|
|
|
870cb9 |
#ifdef _GLIBCXX_USE_WCHAR_T
|
|
|
870cb9 |
+# if __cplusplus <= 201402L
|
|
|
870cb9 |
extern template class basic_string<wchar_t>;
|
|
|
870cb9 |
+# elif ! _GLIBCXX_USE_CXX11_ABI
|
|
|
870cb9 |
+ extern template basic_string<wchar_t>::size_type
|
|
|
870cb9 |
+ basic_string<wchar_t>::_Rep::_S_empty_rep_storage[];
|
|
|
870cb9 |
+# endif
|
|
|
870cb9 |
+
|
|
|
870cb9 |
extern template
|
|
|
870cb9 |
basic_istream<wchar_t>&
|
|
|
870cb9 |
operator>>(basic_istream<wchar_t>&, wstring&);
|
|
|
870cb9 |
@@ -1626,8 +1645,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|
|
870cb9 |
extern template
|
|
|
870cb9 |
basic_istream<wchar_t>&
|
|
|
870cb9 |
getline(basic_istream<wchar_t>&, wstring&);
|
|
|
870cb9 |
-#endif
|
|
|
870cb9 |
-#endif
|
|
|
870cb9 |
+#endif // _GLIBCXX_USE_WCHAR_T
|
|
|
870cb9 |
+#endif // _GLIBCXX_EXTERN_TEMPLATE > 0
|
|
|
870cb9 |
|
|
|
870cb9 |
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
870cb9 |
} // namespace std
|
|
|
870cb9 |
--- /dev/null
|
|
|
870cb9 |
+++ libstdc++-v3/testsuite/21_strings/basic_string/cons/char/86138.cc
|
|
|
870cb9 |
@@ -0,0 +1,30 @@
|
|
|
870cb9 |
+// Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
870cb9 |
+//
|
|
|
870cb9 |
+// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
870cb9 |
+// software; you can redistribute it and/or modify it under the
|
|
|
870cb9 |
+// terms of the GNU General Public License as published by the
|
|
|
870cb9 |
+// Free Software Foundation; either version 3, or (at your option)
|
|
|
870cb9 |
+// any later version.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// This library is distributed in the hope that it will be useful,
|
|
|
870cb9 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
870cb9 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
870cb9 |
+// GNU General Public License for more details.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// You should have received a copy of the GNU General Public License along
|
|
|
870cb9 |
+// with this library; see the file COPYING3. If not see
|
|
|
870cb9 |
+// <http://www.gnu.org/licenses/>.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// { dg-options "-std=gnu++17" }
|
|
|
870cb9 |
+// { dg-do compile { target c++1z } }
|
|
|
870cb9 |
+// { dg-final { scan-assembler-not "_ZNSs4_Rep20_S_empty_rep_storageE:" } }
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+#undef _GLIBCXX_USE_CXX11_ABI
|
|
|
870cb9 |
+#define _GLIBCXX_USE_CXX11_ABI 0
|
|
|
870cb9 |
+#include <string>
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+void
|
|
|
870cb9 |
+test01(std::string* s)
|
|
|
870cb9 |
+{
|
|
|
870cb9 |
+ s->~basic_string();
|
|
|
870cb9 |
+}
|
|
|
870cb9 |
--- /dev/null
|
|
|
870cb9 |
+++ libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/86138.cc
|
|
|
870cb9 |
@@ -0,0 +1,30 @@
|
|
|
870cb9 |
+// Copyright (C) 2018 Free Software Foundation, Inc.
|
|
|
870cb9 |
+//
|
|
|
870cb9 |
+// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
870cb9 |
+// software; you can redistribute it and/or modify it under the
|
|
|
870cb9 |
+// terms of the GNU General Public License as published by the
|
|
|
870cb9 |
+// Free Software Foundation; either version 3, or (at your option)
|
|
|
870cb9 |
+// any later version.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// This library is distributed in the hope that it will be useful,
|
|
|
870cb9 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
870cb9 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
870cb9 |
+// GNU General Public License for more details.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// You should have received a copy of the GNU General Public License along
|
|
|
870cb9 |
+// with this library; see the file COPYING3. If not see
|
|
|
870cb9 |
+// <http://www.gnu.org/licenses/>.
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+// { dg-options "-std=gnu++17" }
|
|
|
870cb9 |
+// { dg-do compile { target c++1z } }
|
|
|
870cb9 |
+// { dg-final { scan-assembler-not "_ZNSbIwSt11char_traitsIwESaIwEE4_Rep20_S_empty_rep_storageE:" } }
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+#undef _GLIBCXX_USE_CXX11_ABI
|
|
|
870cb9 |
+#define _GLIBCXX_USE_CXX11_ABI 0
|
|
|
870cb9 |
+#include <string>
|
|
|
870cb9 |
+
|
|
|
870cb9 |
+void
|
|
|
870cb9 |
+test01(std::wstring* s)
|
|
|
870cb9 |
+{
|
|
|
870cb9 |
+ s->~basic_string();
|
|
|
870cb9 |
+}
|