Commit 0f136367 by Paolo Carlini Committed by Paolo Carlini

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
parent a243fb4a
2009-05-15 Paolo Carlini <paolo.carlini@oracle.com> 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/ * testsuite/26_numerics/random/discrete_distribution/cons/
num_xbound_fun.cc: Minor tweaks. num_xbound_fun.cc: Minor tweaks.
* testsuite/26_numerics/random/piecewise_constant_distribution/ * testsuite/26_numerics/random/piecewise_constant_distribution/
......
// Debug-mode error formatting implementation -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -211,13 +212,21 @@ namespace __gnu_debug ...@@ -211,13 +212,21 @@ namespace __gnu_debug
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it); _M_variant._M_iterator._M_type = &typeid(__it);
#else
_M_variant._M_iterator._M_type = 0;
#endif
_M_variant._M_iterator._M_constness = _M_variant._M_iterator._M_constness =
__is_same<_Safe_iterator<_Iterator, _Sequence>, __is_same<_Safe_iterator<_Iterator, _Sequence>,
typename _Sequence::iterator>:: typename _Sequence::iterator>::
value? __mutable_iterator : __const_iterator; value? __mutable_iterator : __const_iterator;
_M_variant._M_iterator._M_sequence = __it._M_get_sequence(); _M_variant._M_iterator._M_sequence = __it._M_get_sequence();
#ifdef __GXX_RTTI
_M_variant._M_iterator._M_seq_type = &typeid(_Sequence); _M_variant._M_iterator._M_seq_type = &typeid(_Sequence);
#else
_M_variant._M_iterator._M_seq_type = 0;
#endif
if (__it._M_singular()) if (__it._M_singular())
_M_variant._M_iterator._M_state = __singular; _M_variant._M_iterator._M_state = __singular;
...@@ -240,7 +249,11 @@ namespace __gnu_debug ...@@ -240,7 +249,11 @@ namespace __gnu_debug
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it); _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_constness = __mutable_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_sequence = 0;
...@@ -253,7 +266,11 @@ namespace __gnu_debug ...@@ -253,7 +266,11 @@ namespace __gnu_debug
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it); _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_constness = __const_iterator;
_M_variant._M_iterator._M_state = __it? __unknown_state : __singular; _M_variant._M_iterator._M_state = __it? __unknown_state : __singular;
_M_variant._M_iterator._M_sequence = 0; _M_variant._M_iterator._M_sequence = 0;
...@@ -266,7 +283,11 @@ namespace __gnu_debug ...@@ -266,7 +283,11 @@ namespace __gnu_debug
{ {
_M_variant._M_iterator._M_name = __name; _M_variant._M_iterator._M_name = __name;
_M_variant._M_iterator._M_address = &__it; _M_variant._M_iterator._M_address = &__it;
#ifdef __GXX_RTTI
_M_variant._M_iterator._M_type = &typeid(__it); _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_constness = __unknown_constness;
_M_variant._M_iterator._M_state = _M_variant._M_iterator._M_state =
__gnu_debug::__check_singular(__it)? __singular : __unknown_state; __gnu_debug::__check_singular(__it)? __singular : __unknown_state;
...@@ -282,7 +303,11 @@ namespace __gnu_debug ...@@ -282,7 +303,11 @@ namespace __gnu_debug
_M_variant._M_sequence._M_name = __name; _M_variant._M_sequence._M_name = __name;
_M_variant._M_sequence._M_address = _M_variant._M_sequence._M_address =
static_cast<const _Sequence*>(&__seq); static_cast<const _Sequence*>(&__seq);
#ifdef __GXX_RTTI
_M_variant._M_sequence._M_type = &typeid(_Sequence); _M_variant._M_sequence._M_type = &typeid(_Sequence);
#else
_M_variant._M_sequence._M_type = 0;
#endif
} }
template<typename _Sequence> template<typename _Sequence>
...@@ -291,7 +316,11 @@ namespace __gnu_debug ...@@ -291,7 +316,11 @@ namespace __gnu_debug
{ {
_M_variant._M_sequence._M_name = __name; _M_variant._M_sequence._M_name = __name;
_M_variant._M_sequence._M_address = &__seq; _M_variant._M_sequence._M_address = &__seq;
#ifdef __GXX_RTTI
_M_variant._M_sequence._M_type = &typeid(_Sequence); _M_variant._M_sequence._M_type = &typeid(_Sequence);
#else
_M_variant._M_sequence._M_type = 0;
#endif
} }
void void
......
// Debugging mode support code -*- C++ -*- // 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. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
...@@ -298,9 +298,12 @@ namespace __gnu_debug ...@@ -298,9 +298,12 @@ namespace __gnu_debug
} }
else if (strcmp(__name, "type") == 0) else if (strcmp(__name, "type") == 0)
{ {
assert(_M_variant._M_iterator._M_type); if (!_M_variant._M_iterator._M_type)
// TBD: demangle! __formatter->_M_print_word("<unknown type>");
__formatter->_M_print_word(_M_variant._M_iterator._M_type->name()); else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_iterator.
_M_type->name());
} }
else if (strcmp(__name, "constness") == 0) else if (strcmp(__name, "constness") == 0)
{ {
...@@ -310,7 +313,9 @@ namespace __gnu_debug ...@@ -310,7 +313,9 @@ namespace __gnu_debug
"constant", "constant",
"mutable" "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) else if (strcmp(__name, "state") == 0)
{ {
...@@ -322,7 +327,8 @@ namespace __gnu_debug ...@@ -322,7 +327,8 @@ namespace __gnu_debug
"dereferenceable", "dereferenceable",
"past-the-end" "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) else if (strcmp(__name, "sequence") == 0)
{ {
...@@ -333,9 +339,12 @@ namespace __gnu_debug ...@@ -333,9 +339,12 @@ namespace __gnu_debug
} }
else if (strcmp(__name, "seq_type") == 0) else if (strcmp(__name, "seq_type") == 0)
{ {
// TBD: demangle! if (!_M_variant._M_iterator._M_seq_type)
assert(_M_variant._M_iterator._M_seq_type); __formatter->_M_print_word("<unknown seq_type>");
__formatter->_M_print_word(_M_variant._M_iterator._M_seq_type->name()); else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_iterator.
_M_seq_type->name());
} }
else else
assert(false); assert(false);
...@@ -356,9 +365,12 @@ namespace __gnu_debug ...@@ -356,9 +365,12 @@ namespace __gnu_debug
} }
else if (strcmp(__name, "type") == 0) else if (strcmp(__name, "type") == 0)
{ {
// TBD: demangle! if (!_M_variant._M_sequence._M_type)
assert(_M_variant._M_sequence._M_type); __formatter->_M_print_word("<unknown type>");
__formatter->_M_print_word(_M_variant._M_sequence._M_type->name()); else
// TBD: demangle!
__formatter->_M_print_word(_M_variant._M_sequence.
_M_type->name());
} }
else else
assert(false); assert(false);
......
// -*- 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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment