aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-05-15 22:25:24 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-05-15 22:25:24 +0000
commit0f136367bcba1783495ad7edaa81bd61fd284ac6 (patch)
tree5d4aa91441f881772ffaeff2a995dc4c43cd5b00 /libstdc++-v3
parenta243fb4a5bb588bbb4b7292a410b9594d7bf6e8d (diff)
downloadgcc-0f136367bcba1783495ad7edaa81bd61fd284ac6.zip
gcc-0f136367bcba1783495ad7edaa81bd61fd284ac6.tar.gz
gcc-0f136367bcba1783495ad7edaa81bd61fd284ac6.tar.bz2
re PR libstdc++/40160 (-fno-rtti vs _GLIBCXX_DEBUG)
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. From-SVN: r147599
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/debug/formatter.h31
-rw-r--r--libstdc++-v3/src/debug.cc36
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/40160.cc26
4 files changed, 90 insertions, 13 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 0c79acd..a63520d 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
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.
+
+2009-05-15 Paolo Carlini <paolo.carlini@oracle.com>
+
* testsuite/26_numerics/random/discrete_distribution/cons/
num_xbound_fun.cc: Minor tweaks.
* testsuite/26_numerics/random/piecewise_constant_distribution/
diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h
index 6dffc6b..b4b4389 100644
--- a/libstdc++-v3/include/debug/formatter.h
+++ b/libstdc++-v3/include/debug/formatter.h
@@ -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 @@ namespace __gnu_debug
{
_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 @@ namespace __gnu_debug
{
_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 @@ namespace __gnu_debug
{
_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 @@ namespace __gnu_debug
{
_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 @@ namespace __gnu_debug
_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 @@ namespace __gnu_debug
{
_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
diff --git a/libstdc++-v3/src/debug.cc b/libstdc++-v3/src/debug.cc
index 6ce2e10..bb0aebe 100644
--- a/libstdc++-v3/src/debug.cc
+++ b/libstdc++-v3/src/debug.cc
@@ -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 @@ namespace __gnu_debug
}
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 @@ namespace __gnu_debug
"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 @@ namespace __gnu_debug
"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 @@ namespace __gnu_debug
}
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 @@ namespace __gnu_debug
}
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);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc b/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc
new file mode 100644
index 0000000..088e594
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc
@@ -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>