This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] libstdc++/40160
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Sat, 16 May 2009 00:26:22 +0200
- Subject: [v3] libstdc++/40160
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
////////////////////
2009-05-15 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/40160
* include/debug/formatter.h (_Parameter::_Parameter): Don't use
typeid when __GXX_RTTI is undefined.
* src/debug.cc (_Error_formatter::_Parameter::_M_print_field): Adjust
for null _M_variant._M_iterator._M_type,
_M_variant._M_iterator._M_seq_type, _M_variant._M_sequence._M_type.
* testsuite/21_strings/basic_string/40160.cc: New.
Index: src/debug.cc
===================================================================
--- src/debug.cc (revision 147567)
+++ src/debug.cc (working copy)
@@ -1,6 +1,6 @@
// Debugging mode support code -*- C++ -*-
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -298,9 +298,12 @@
}
else if (strcmp(__name, "type") == 0)
{
- assert(_M_variant._M_iterator._M_type);
- // TBD: demangle!
- __formatter->_M_print_word(_M_variant._M_iterator._M_type->name());
+ if (!_M_variant._M_iterator._M_type)
+ __formatter->_M_print_word("<unknown type>");
+ else
+ // TBD: demangle!
+ __formatter->_M_print_word(_M_variant._M_iterator.
+ _M_type->name());
}
else if (strcmp(__name, "constness") == 0)
{
@@ -310,7 +313,9 @@
"constant",
"mutable"
};
- __formatter->_M_print_word(__constness_names[_M_variant._M_iterator._M_constness]);
+ __formatter->_M_print_word(__constness_names[_M_variant.
+ _M_iterator.
+ _M_constness]);
}
else if (strcmp(__name, "state") == 0)
{
@@ -322,7 +327,8 @@
"dereferenceable",
"past-the-end"
};
- __formatter->_M_print_word(__state_names[_M_variant._M_iterator._M_state]);
+ __formatter->_M_print_word(__state_names[_M_variant.
+ _M_iterator._M_state]);
}
else if (strcmp(__name, "sequence") == 0)
{
@@ -333,9 +339,12 @@
}
else if (strcmp(__name, "seq_type") == 0)
{
- // TBD: demangle!
- assert(_M_variant._M_iterator._M_seq_type);
- __formatter->_M_print_word(_M_variant._M_iterator._M_seq_type->name());
+ if (!_M_variant._M_iterator._M_seq_type)
+ __formatter->_M_print_word("<unknown seq_type>");
+ else
+ // TBD: demangle!
+ __formatter->_M_print_word(_M_variant._M_iterator.
+ _M_seq_type->name());
}
else
assert(false);
@@ -356,9 +365,12 @@
}
else if (strcmp(__name, "type") == 0)
{
- // TBD: demangle!
- assert(_M_variant._M_sequence._M_type);
- __formatter->_M_print_word(_M_variant._M_sequence._M_type->name());
+ if (!_M_variant._M_sequence._M_type)
+ __formatter->_M_print_word("<unknown type>");
+ else
+ // TBD: demangle!
+ __formatter->_M_print_word(_M_variant._M_sequence.
+ _M_type->name());
}
else
assert(false);
Index: include/debug/formatter.h
===================================================================
--- include/debug/formatter.h (revision 147567)
+++ include/debug/formatter.h (working copy)
@@ -1,6 +1,7 @@
// Debug-mode error formatting implementation -*- C++ -*-
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -211,13 +212,21 @@
{
_M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it;
+#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it);
+#else
+ _M_variant._M_iterator._M_type = 0;
+#endif
_M_variant._M_iterator._M_constness =
__is_same<_Safe_iterator<_Iterator, _Sequence>,
typename _Sequence::iterator>::
value? __mutable_iterator : __const_iterator;
_M_variant._M_iterator._M_sequence = __it._M_get_sequence();
+#ifdef __GXX_RTTI
_M_variant._M_iterator._M_seq_type = &typeid(_Sequence);
+#else
+ _M_variant._M_iterator._M_seq_type = 0;
+#endif
if (__it._M_singular())
_M_variant._M_iterator._M_state = __singular;
@@ -240,7 +249,11 @@
{
_M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it;
+#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it);
+#else
+ _M_variant._M_iterator._M_type = 0;
+#endif
_M_variant._M_iterator._M_constness = __mutable_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0;
@@ -253,7 +266,11 @@
{
_M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it;
+#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it);
+#else
+ _M_variant._M_iterator._M_type = 0;
+#endif
_M_variant._M_iterator._M_constness = __const_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0;
@@ -266,7 +283,11 @@
{
_M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it;
+#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it);
+#else
+ _M_variant._M_iterator._M_type = 0;
+#endif
_M_variant._M_iterator._M_constness = __unknown_constness;
_M_variant._M_iterator._M_state =
__gnu_debug::__check_singular(__it)? __singular : __unknown_state;
@@ -282,7 +303,11 @@
_M_variant._M_sequence._M_name = __name;
_M_variant._M_sequence._M_address =
static_cast<const _Sequence*>(&__seq);
+#ifdef __GXX_RTTI
_M_variant._M_sequence._M_type = &typeid(_Sequence);
+#else
+ _M_variant._M_sequence._M_type = 0;
+#endif
}
template<typename _Sequence>
@@ -291,7 +316,11 @@
{
_M_variant._M_sequence._M_name = __name;
_M_variant._M_sequence._M_address = &__seq;
+#ifdef __GXX_RTTI
_M_variant._M_sequence._M_type = &typeid(_Sequence);
+#else
+ _M_variant._M_sequence._M_type = 0;
+#endif
}
void
Index: testsuite/21_strings/basic_string/40160.cc
===================================================================
--- testsuite/21_strings/basic_string/40160.cc (revision 0)
+++ testsuite/21_strings/basic_string/40160.cc (revision 0)
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+
+// { dg-options "-fno-rtti -D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/40160
+#include <string>