summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 14:56:46 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-09-17 14:56:46 +0000
commit6904f6c1b9a6a143bf44362b00fa4b1a7e517718 (patch)
treed6cce82070a2a2dcc37f72689170cf83ea4c7782
parent947ed59a55265a3cfc28416744feab6d0b614269 (diff)
downloadgcc-6904f6c1b9a6a143bf44362b00fa4b1a7e517718.tar.gz
Only do shrink_to_fit() when exceptions enabled
* include/bits/allocator.h (__shrink_to_fit_aux<T, true>::_S_do_it): Do nothing if exceptions are disabled. * include/bits/basic_string.h (basic_string::shrink_to_fit): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227870 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/allocator.h8
-rw-r--r--libstdc++-v3/include/bits/basic_string.h12
3 files changed, 20 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index b8c11843632..2bcfa161fcf 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-17 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/bits/allocator.h (__shrink_to_fit_aux<T, true>::_S_do_it):
+ Do nothing if exceptions are disabled.
+ * include/bits/basic_string.h (basic_string::shrink_to_fit): Likewise.
+
2015-09-16 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/67173
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 6fd3214cd02..0131521c5cd 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -209,15 +209,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static bool
_S_do_it(_Tp& __c) noexcept
{
- __try
+#if __cpp_exceptions
+ try
{
_Tp(__make_move_if_noexcept_iterator(__c.begin()),
__make_move_if_noexcept_iterator(__c.end()),
__c.get_allocator()).swap(__c);
return true;
}
- __catch(...)
+ catch(...)
{ return false; }
+#else
+ return false;
+#endif
}
};
#endif
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index e6e7bb525ba..b5e7e3628c6 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -833,13 +833,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
void
shrink_to_fit() noexcept
{
+#if __cpp_exceptions
if (capacity() > size())
{
- __try
+ try
{ reserve(0); }
- __catch(...)
+ catch(...)
{ }
}
+#endif
}
#endif
@@ -3282,12 +3284,14 @@ _GLIBCXX_END_NAMESPACE_CXX11
void
shrink_to_fit() _GLIBCXX_NOEXCEPT
{
+#if __cpp_exceptions
if (capacity() > size())
{
- __try
+ try
{ reserve(0); }
- __catch(...)
+ catch(...)
{ }
+#endif
}
}
#endif