aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2015-09-17 15:56:46 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2015-09-17 15:56:46 +0100
commit99f04955edfdff11e3270df6326f426a29e1ec5a (patch)
treed6cce82070a2a2dcc37f72689170cf83ea4c7782
parent385399a8759c233f487ddd7e158802a1ee4f960d (diff)
downloadgcc-99f04955edfdff11e3270df6326f426a29e1ec5a.zip
gcc-99f04955edfdff11e3270df6326f426a29e1ec5a.tar.gz
gcc-99f04955edfdff11e3270df6326f426a29e1ec5a.tar.bz2
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. From-SVN: r227870
-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 b8c1184..2bcfa16 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 6fd3214..0131521 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 e6e7bb5..b5e7e36 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