This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Does --enable-clocale=gnu work on Linux/ia64?


On Sun, Nov 25, 2001 at 01:19:51AM -0800, H . J . Lu wrote:
> On Sat, Nov 24, 2001 at 08:36:12PM -0800, Benjamin Kosnik wrote:
> > 
> > > Well, I tried --enable-clocale=gnu again with gcc-3.1 from CVS on
> > > Linux/ia64. Now I got this problem:
> > > 
> > >    _Intl>::_M_initialize_moneypunct(__locale_struct*) [with _CharT = wchar_t, 
> > >    bool _Intl = false]':
> > > moneypunct.cc:401: reinterpret_cast from `char*' to `wchar_t' loses precision
> > > moneypunct.cc:402: reinterpret_cast from `char*' to `wchar_t' loses precision
> > > numpunct.cc: In member function `void 
> > >    std::numpunct<_CharT>::_M_initialize_numpunct(__locale_struct*) [with _CharT 
> > >    = wchar_t]':
> > > numpunct.cc:80: reinterpret_cast from `char*' to `wchar_t' loses precision
> > > numpunct.cc:81: reinterpret_cast from `char*' to `wchar_t' loses precision
> > > make[5]: *** [numpunct.lo] Error 1
> > > make[5]: *** Waiting for unfinished jobs....
> > 
> > Which is this:
> >   _M_decimal_point = 
> > reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, 
> > __cloc));
> > 
> > 
> > Why does this work on x86 but not ia64?
> > 
> >  > > Has anyone tried --enable-clocale=gnu on Linux/ia64?
> > 
> > Nope. It seems to work on powerpc though.
> 
> Well, on x86 and powerpc, wchar_t is long int. Gcc won't complain about
> casting from char* to wchar_t. However, on ia64, wchar_t is int. Gcc is
> not very happy. I think that part of libstdc++ is pretty much broken.
> 
> 

This patch seems to work for me on Linux/ia64 and Linux/x86. But I
don't know if it is 100% correct C++ :-(.


H.J.
---
2001-11-25  H.J. Lu <hjl@gnu.org>

	* config/locale/moneypunct_members_gnu.cc
	(_M_initialize_moneypunct): Cast "char *" to "long int" before
	casting to wchar_t for _NL_NUMERIC_DECIMAL_POINT_WC and
	_NL_NUMERIC_THOUSANDS_SEP_WC.
	* config/locale/numpunct_members_gnu.cc 
	(_M_initialize_numpunct): Likewise.

--- libstdc++-v3/config/locale/moneypunct_members_gnu.cc.gnu	Thu Nov 22 17:37:07 2001
+++ libstdc++-v3/config/locale/moneypunct_members_gnu.cc	Sun Nov 25 16:25:11 2001
@@ -319,8 +319,11 @@ namespace std
       else
 	{
 	  // Named locale.
-	  _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
-	  _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  long int ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
+	  _M_decimal_point = (wchar_t) ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  _M_thousands_sep = (wchar_t) ch;
 	  _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
 
 	  mbstate_t __state;
@@ -398,8 +401,11 @@ namespace std
       else
 	{
 	  // Named locale.
-	  _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
-	  _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  long int ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
+	  _M_decimal_point = (wchar_t) ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  _M_thousands_sep = (wchar_t) ch;
 	  _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
 
 	  mbstate_t __state;
--- libstdc++-v3/config/locale/numpunct_members_gnu.cc.gnu	Mon Aug 27 23:19:33 2001
+++ libstdc++-v3/config/locale/numpunct_members_gnu.cc	Sun Nov 25 16:25:55 2001
@@ -77,8 +77,11 @@ namespace std
       else
 	{
 	  // Named locale.
-	  _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
-	  _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  long int ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
+	  _M_decimal_point = (wchar_t) ch;
+	  ch = reinterpret_cast<long int>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+	  _M_thousands_sep = (wchar_t) ch;
 	  _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
 	}
       // NB: There is no way to extact this info from posix locales.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]