diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0c79acddf9bff0c49648136998add9156db622ca..a63520db39f3786bd5abf511de54f98093bfa4cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +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/ diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h index 6dffc6b786dac549e84d7b7320938c8ec6cb4616..b4b43896d04a0d4f9f8df26d85f40197a945bae9 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 6ce2e101f252f4d7283231b33dd121e1d8fcbd24..bb0aebe433a45ea588f99a8e5542f8d88d81ddc8 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 0000000000000000000000000000000000000000..088e594cbe42bc030acd8701421118560485f848 --- /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>