This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] libstdc++/4749
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Subject: [v3] libstdc++/4749
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Wed, 31 Oct 2001 12:04:53 -0800
This will remove the unexpected failure for libstdc++ test runs.
Per the standard, implementations are only required to provide
specializations for char and wchar_t, although all instantiations
should be able to compile. This is now the case for codecvt:
specializations like
// Should be able to instantiate this for other types besides char, wchar_t
class gnu_codecvt: public std::codecvt<unsigned char, unsigned long, char>
{ };
void test02()
{
gnu_codecvt facet01;
}
Will compile but not link.
So far, iostreams and locales have implemented this unevenly: some of
the instantiations provide default, generic implementations. Some do
not, like codecvt.
I'm not quite sure what to do, but I'm leaning towards removing the
generics and just providing the required definitions, at least for all
of locale. I think this makes it easier for people to do their own
thing WRT using the standard library on non-standard types.
At some point, this should be revisited and made uniform.
-benjamin
tested/x86-linux
2001-10-31 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/4749
* include/bits/codecvt.h: Add virtual member function declarations.
* src/codecvt.cc: Tweaks.
* testsuite/22_locale/codecvt.cc: Test compilation only,
non-required facets not required to have linkage.
Index: include/bits/codecvt.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/codecvt.h,v
retrieving revision 1.16
diff -c -p -r1.16 codecvt.h
*** codecvt.h 2001/08/08 02:48:59 1.16
--- codecvt.h 2001/10/31 19:57:14
***************
*** 171,176 ****
--- 171,205 ----
protected:
virtual
~codecvt() { }
+
+ virtual result
+ do_out(state_type& __state, const intern_type* __from,
+ const intern_type* __from_end, const intern_type*& __from_next,
+ extern_type* __to, extern_type* __to_end,
+ extern_type*& __to_next) const;
+
+ virtual result
+ do_unshift(state_type& __state, extern_type* __to,
+ extern_type* __to_end, extern_type*& __to_next) const;
+
+ virtual result
+ do_in(state_type& __state, const extern_type* __from,
+ const extern_type* __from_end, const extern_type*& __from_next,
+ intern_type* __to, intern_type* __to_end,
+ intern_type*& __to_next) const;
+
+ virtual int
+ do_encoding() const throw();
+
+ virtual bool
+ do_always_noconv() const throw();
+
+ virtual int
+ do_length(const state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const;
+
+ virtual int
+ do_max_length() const throw();
};
template<typename _InternT, typename _ExternT, typename _StateT>
***************
*** 302,308 ****
#endif
#endif // _CPP_BITS_CODECVT_H
-
-
-
-
--- 331,333 ----
Index: src/codecvt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/codecvt.cc,v
retrieving revision 1.7
diff -c -p -r1.7 codecvt.cc
*** codecvt.cc 2001/08/08 02:49:01 1.7
--- codecvt.cc 2001/10/31 19:57:16
*************** namespace std
*** 46,52 ****
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_out(state_type& /*__state*/, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
--- 46,52 ----
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_out(state_type&, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
*************** namespace std
*** 60,67 ****
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_unshift(state_type& /*__state*/, extern_type* __to,
! extern_type* /*__to_end*/, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
--- 60,67 ----
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_unshift(state_type&, extern_type* __to,
! extern_type*, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
*************** namespace std
*** 69,75 ****
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_in(state_type& /*__state*/, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
--- 69,75 ----
codecvt_base::result
codecvt<char, char, mbstate_t>::
! do_in(state_type&, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
*************** namespace std
*** 93,99 ****
int
codecvt<char, char, mbstate_t>::
! do_length (const state_type& /*__state*/, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
--- 93,99 ----
int
codecvt<char, char, mbstate_t>::
! do_length (const state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
*************** namespace std
*** 142,149 ****
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
! do_unshift(state_type& /*__state*/, extern_type* __to,
! extern_type* /*__to_end*/, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
--- 142,149 ----
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
! do_unshift(state_type&, extern_type* __to,
! extern_type*, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
*************** namespace std
*** 190,196 ****
int
codecvt<wchar_t, char, mbstate_t>::
! do_length(const state_type& /*__state*/, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
--- 190,196 ----
int
codecvt<wchar_t, char, mbstate_t>::
! do_length(const state_type&, const extern_type* __from,
const extern_type* __end, size_t __max) const
{ return min(__max, static_cast<size_t>(__end - __from)); }
*************** namespace std
*** 200,204 ****
{ return 1; }
#endif // _GLIBCPP_USE_WCHAR_T
} // namespace std
-
-
--- 200,202 ----
Index: testsuite/22_locale/codecvt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/codecvt.cc,v
retrieving revision 1.1
diff -c -p -r1.1 codecvt.cc
*** codecvt.cc 2001/08/28 06:19:35 1.1
--- codecvt.cc 2001/10/31 19:57:17
***************
*** 20,25 ****
--- 20,27 ----
// 22.2.1.5 Template class codecvt
+ // { dg-do compile }
+
#include <locale>
void test01()