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>
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/
......
// 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
......
// 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);
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());
__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)
{
if (!_M_variant._M_iterator._M_seq_type)
__formatter->_M_print_word("<unknown seq_type>");
else
// TBD: demangle!
assert(_M_variant._M_iterator._M_seq_type);
__formatter->_M_print_word(_M_variant._M_iterator._M_seq_type->name());
__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)
{
if (!_M_variant._M_sequence._M_type)
__formatter->_M_print_word("<unknown type>");
else
// TBD: demangle!
assert(_M_variant._M_sequence._M_type);
__formatter->_M_print_word(_M_variant._M_sequence._M_type->name());
__formatter->_M_print_word(_M_variant._M_sequence.
_M_type->name());
}
else
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