This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Mar 2007 16:58:02 -0000
- Subject: [Bug libstdc++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
- References: <bug-31246-1902@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-03-17 16:58 -------
Lets look at the IR:
;; Function __gnu_debug::_Safe_iterator<_Iterator, _Sequence>::_Safe_iterator()
[with _Iterator = __gnu_cxx::__normal_iterator<int*, __gnu_norm::vector<int,
std::allocator<int> > >, _Sequence = __gnu_debug_def::vector<int,
std::allocator<int> >]
(_ZN11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiN10__gnu_norm6vectorIiSaIiEEEEEN15__gnu_debug_def6vectorIiS6_EEEC4Ev
*INTERNAL* )
;; enabled by -tree-original
{
<<cleanup_point <<< Unknown tree: expr_stmt
__base_ctor (&((struct _Safe_iterator<__gnu_cxx::__normal_iterator<int*,
__gnu_norm::vector<int, std::allocator<int> > >,__gnu_debug_def::vector<int,
std::allocator<int> > > *) this)->D.12082) >>>
>>;
try
{
<<cleanup_point <<< Unknown tree: expr_stmt
__comp_ctor (&((struct _Safe_iterator<__gnu_cxx::__normal_iterator<int*,
__gnu_norm::vector<int, std::allocator<int> > >,__gnu_debug_def::vector<int,
std::allocator<int> > > *) this)->_M_current) >>>
>>;
}
catch
{
__base_dtor ((struct _Safe_iterator_base *) this);
}
}
and the constructor for ->M_current:
__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<int*,
__gnu_norm::vector<int, std::allocator<int> > >, __gnu_debug_def::vector<int,
std::allocator<int> > >::~_Safe_iterator() (this, __in_chrg)
{
struct _Safe_iterator_base * this.102;
[/usr/include/c++/4.0.0/debug/safe_iterator.h : 65] {
[/usr/include/c++/4.0.0/debug/safe_iterator.h : 65] try
{
}
finally
{
[/usr/include/c++/4.0.0/debug/safe_iterator.h : 65] this.102 = (struct
_Safe_iterator_base *) this;
[/usr/include/c++/4.0.0/debug/safe_iterator.h : 65] __base_dtor
(this.102);
}
}
[/usr/include/c++/4.0.0/debug/safe_iterator.h : 65] <D12095>:;
}
So the constructor for that cannot throw so the catch part is removed in both
cases.
The warning is not strange and is correct in that the __base_dtor cannot be
called ever.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246