This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.0 PATCH] Fix for PR21951
- From: Dan Kegel <dank at kegel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 11 Jun 2005 17:45:28 -0700
- Subject: [4.0 PATCH] Fix for PR21951
C++ programs compiled with -fno-exceptions fail with gcc-4.0.0
because of false positive warnings about control reaching
the end of a inlined function without returning a value
(see http://gcc.gnu.org/PR21951).
While user code can easily work around this, it also
affects five include files in libstdc++. Shops that compile everything
with -Werror -fno-exceptions will not be able to use
gcc-4.0.0 without a fix like the following (also attached to the PR).
It fixes the problem for me, and doesn't cause any
obvious trouble when building or testing g++.
I don't have a copyright assignment, but as the patch is
rather trivial, perhaps it or something similar can be applied anyway
in time for 4.0.1 or 4.0.2.
Thanks!
- Dan
2005-06-11 Dan Kegel <dank@kegel.com>
PR c++/21951: avoid appearing to hit end of function when compiled with -fno-exceptions
* libstdc++-v3/include/bits/stl_vector.h
* libstdc++-v3/include/bits/stl_uninitialized.h
* libstdc++-v3/include/ext/rope
* libstdc++-v3/include/ext/memory
* libstdc++-v3/include/ext/hashtable.h
--- gcc-4.0.1-20050607/libstdc++-v3/include/bits/stl_vector.h.old 2005-06-11 03:58:20.000000000 -0700
+++ gcc-4.0.1-20050607/libstdc++-v3/include/bits/stl_vector.h 2005-06-11 04:01:21.000000000 -0700
@@ -765,13 +765,13 @@
{
std::__uninitialized_copy_a(__first, __last, __result,
this->get_allocator());
- return __result;
}
catch(...)
{
_M_deallocate(__result, __n);
__throw_exception_again;
}
+ return __result;
}
--- gcc-4.0.1-20050607/libstdc++-v3/include/bits/stl_uninitialized.h.old 2005-06-11 03:58:20.000000000 -0700
+++ gcc-4.0.1-20050607/libstdc++-v3/include/bits/stl_uninitialized.h 2005-06-11 04:05:18.990003248 -0700
@@ -84,13 +84,13 @@
{
for (; __first != __last; ++__first, ++__cur)
std::_Construct(&*__cur, *__first);
- return __cur;
}
catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
+ return __cur;
}
/**
@@ -236,13 +236,13 @@
{
for (; __first != __last; ++__first, ++__cur)
__alloc.construct(&*__cur, *__first);
- return __cur;
}
catch(...)
{
std::_Destroy(__result, __cur, __alloc);
__throw_exception_again;
}
+ return __cur;
}
template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
@@ -337,11 +337,13 @@
{
return std::__uninitialized_copy_a(__first2, __last2, __mid, __alloc);
}
+#ifdef __EXCEPTIONS // work around http://gcc.gnu.org/PR21951 in gcc-4.0 only
catch(...)
{
std::_Destroy(__result, __mid, __alloc);
__throw_exception_again;
}
+#endif
}
// __uninitialized_fill_copy
@@ -360,11 +362,13 @@
{
return std::__uninitialized_copy_a(__first, __last, __mid, __alloc);
}
+#ifdef __EXCEPTIONS // work around http://gcc.gnu.org/PR21951 in gcc-4.0 only
catch(...)
{
std::_Destroy(__result, __mid, __alloc);
__throw_exception_again;
}
+#endif
}
// __uninitialized_copy_fill
--- gcc-4.0.1-20050607/libstdc++-v3/include/ext/rope.old 2005-06-11 03:58:20.000000000 -0700
+++ gcc-4.0.1-20050607/libstdc++-v3/include/ext/rope 2005-06-11 04:13:26.628870872 -0700
@@ -1645,11 +1645,13 @@
_S_cond_store_eos(__buf[__size]);
try
{ return _S_new_RopeLeaf(__buf, __size, __a); }
+#ifdef __EXCEPTIONS // work around http://gcc.gnu.org/PR21951 in gcc-4.0 only
catch(...)
{
_RopeRep::__STL_FREE_STRING(__buf, __size, __a);
__throw_exception_again;
}
+#endif
}
// Concatenation of nonempty strings.
--- gcc-4.0.1-20050607/libstdc++-v3/include/ext/memory.old 2005-06-11 03:58:20.000000000 -0700
+++ gcc-4.0.1-20050607/libstdc++-v3/include/ext/memory 2005-06-11 04:13:52.897877376 -0700
@@ -85,11 +85,13 @@
std::_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
+#ifdef __EXCEPTIONS // work around http://gcc.gnu.org/PR21951 in gcc-4.0 only
catch(...)
{
std::_Destroy(__result, __cur);
__throw_exception_again;
}
+#endif
}
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
@@ -144,11 +146,13 @@
__alloc.construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
+#ifdef __EXCEPTIONS // work around http://gcc.gnu.org/PR21951 in gcc-4.0 only
catch(...)
{
std::_Destroy(__result, __cur, __alloc);
__throw_exception_again;
}
+#endif
}
template<typename _InputIter, typename _Size, typename _ForwardIter,
--- gcc-4.0.1-20050607/libstdc++-v3/include/ext/hashtable.h.old 2005-06-11 03:58:20.000000000 -0700
+++ gcc-4.0.1-20050607/libstdc++-v3/include/ext/hashtable.h 2005-06-11 04:14:28.384482592 -0700
@@ -607,13 +607,13 @@
try
{
this->get_allocator().construct(&__n->_M_val, __obj);
- return __n;
}
catch(...)
{
_M_put_node(__n);
__throw_exception_again;
}
+ return __n;
}
void
--
Trying to get a job as a c++ developer? See http://kegel.com/academy/getting-hired.html