re PR libstdc++/34680 (Unconditional use of dynamic_cast in locale_facets.tcc breaks compilation with -fno-rtti)
2008-01-07 Paolo Carlini <pcarlini@suse.de> PR libstdc++/34680 * include/bits/locale_classes.h (has_facet<>, use_facet<>): Do not use dynamic_cast when run-time type identification is disabled; do not mark inline; only declare, define... * include/bits/locale_classes.tcc: ... here. From-SVN: r131372
This commit is contained in:
parent
bd5db9de0d
commit
32f1271c4f
|
@ -1,3 +1,11 @@
|
||||||
|
2008-01-07 Paolo Carlini <pcarlini@suse.de>
|
||||||
|
|
||||||
|
PR libstdc++/34680
|
||||||
|
* include/bits/locale_classes.h (has_facet<>, use_facet<>): Do not
|
||||||
|
use dynamic_cast when run-time type identification is disabled; do
|
||||||
|
not mark inline; only declare, define...
|
||||||
|
* include/bits/locale_classes.tcc: ... here.
|
||||||
|
|
||||||
2008-01-06 Ted Phelps <phelps@gnusto.com>
|
2008-01-06 Ted Phelps <phelps@gnusto.com>
|
||||||
|
|
||||||
PR c++/34152
|
PR c++/34152
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Locale support -*- C++ -*-
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
// 2006, 2007
|
// 2006, 2007, 2008
|
||||||
// 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
|
||||||
|
@ -574,14 +574,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
* @return true if locale contains a facet of type Facet, else false.
|
* @return true if locale contains a facet of type Facet, else false.
|
||||||
*/
|
*/
|
||||||
template<typename _Facet>
|
template<typename _Facet>
|
||||||
inline bool
|
bool
|
||||||
has_facet(const locale& __loc) throw()
|
has_facet(const locale& __loc) throw();
|
||||||
{
|
|
||||||
const size_t __i = _Facet::id._M_id();
|
|
||||||
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
|
||||||
return __i < __loc._M_impl->_M_facets_size
|
|
||||||
&& dynamic_cast<const _Facet*>(__facets[__i]) != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return a facet.
|
* @brief Return a facet.
|
||||||
|
@ -597,15 +591,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
* @throw std::bad_cast if locale doesn't contain a facet of type Facet.
|
* @throw std::bad_cast if locale doesn't contain a facet of type Facet.
|
||||||
*/
|
*/
|
||||||
template<typename _Facet>
|
template<typename _Facet>
|
||||||
inline const _Facet&
|
const _Facet&
|
||||||
use_facet(const locale& __loc)
|
use_facet(const locale& __loc);
|
||||||
{
|
|
||||||
const size_t __i = _Facet::id._M_id();
|
|
||||||
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
|
||||||
if (__i >= __loc._M_impl->_M_facets_size || __facets[__i] == NULL)
|
|
||||||
__throw_bad_cast();
|
|
||||||
return dynamic_cast<const _Facet&>(*__facets[__i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Locale support -*- C++ -*-
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
// Copyright (C) 2007, 2008 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
|
||||||
|
@ -44,7 +44,8 @@
|
||||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
template<typename _Facet>
|
template<typename _Facet>
|
||||||
locale::locale(const locale& __other, _Facet* __f)
|
locale::
|
||||||
|
locale(const locale& __other, _Facet* __f)
|
||||||
{
|
{
|
||||||
_M_impl = new _Impl(*__other._M_impl, 1);
|
_M_impl = new _Impl(*__other._M_impl, 1);
|
||||||
|
|
||||||
|
@ -61,7 +62,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
template<typename _Facet>
|
template<typename _Facet>
|
||||||
locale
|
locale
|
||||||
locale::combine(const locale& __other) const
|
locale::
|
||||||
|
combine(const locale& __other) const
|
||||||
{
|
{
|
||||||
_Impl* __tmp = new _Impl(*_M_impl, 1);
|
_Impl* __tmp = new _Impl(*_M_impl, 1);
|
||||||
try
|
try
|
||||||
|
@ -78,7 +80,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
bool
|
bool
|
||||||
locale::operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
|
locale::
|
||||||
|
operator()(const basic_string<_CharT, _Traits, _Alloc>& __s1,
|
||||||
const basic_string<_CharT, _Traits, _Alloc>& __s2) const
|
const basic_string<_CharT, _Traits, _Alloc>& __s2) const
|
||||||
{
|
{
|
||||||
typedef std::collate<_CharT> __collate_type;
|
typedef std::collate<_CharT> __collate_type;
|
||||||
|
@ -88,6 +91,36 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename _Facet>
|
||||||
|
bool
|
||||||
|
has_facet(const locale& __loc) throw()
|
||||||
|
{
|
||||||
|
const size_t __i = _Facet::id._M_id();
|
||||||
|
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
||||||
|
return (__i < __loc._M_impl->_M_facets_size
|
||||||
|
#ifdef __GXX_RTTI
|
||||||
|
&& dynamic_cast<const _Facet*>(__facets[__i]));
|
||||||
|
#else
|
||||||
|
&& static_cast<const _Facet*>(__facets[__i]));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _Facet>
|
||||||
|
const _Facet&
|
||||||
|
use_facet(const locale& __loc)
|
||||||
|
{
|
||||||
|
const size_t __i = _Facet::id._M_id();
|
||||||
|
const locale::facet** __facets = __loc._M_impl->_M_facets;
|
||||||
|
if (__i >= __loc._M_impl->_M_facets_size || !__facets[__i])
|
||||||
|
__throw_bad_cast();
|
||||||
|
#ifdef __GXX_RTTI
|
||||||
|
return dynamic_cast<const _Facet&>(*__facets[__i]);
|
||||||
|
#else
|
||||||
|
return static_cast<const _Facet&>(*__facets[__i]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Generic version does nothing.
|
// Generic version does nothing.
|
||||||
template<typename _CharT>
|
template<typename _CharT>
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue