------- Comment #10 from dave at hiauly1 dot hia dot nrc dot ca  2007-04-02 
03:36 -------
Subject: Re:  FAIL: 22_locale/time_get/get_date/wchar_t/4.cc execution test

> ------- Comment #8 from pcarlini at suse dot de  2007-04-02 00:53 -------
> One last remark: when something having to do with named locales doesn't work,
> often I find myself checking whether corresponding "C" code works. In this
> case, if __format is wrong, which means apparently that 
> _M_data->_M_date_format
> is wrong, I suggest preparing a plain "C" snippet equivalent to the code in
> config/locale/gnu/time_members.cc which sets _M_data->_M_date_format, 
> something
> like:
> 
>   loc = newlocale(1 << LC_ALL, __s, 0);
> 
>   union { char *__s; wchar_t *__w; } __u;
>   __u.__s = __nl_langinfo_l(_NL_WD_FMT, loc);
> 
>   const wchar_t* pp = __u.__w;

Thanks for the tip.  The following doesn't work on hppa but
does on x86:

#include <locale.h>
#include <langinfo.h>
#include <wchar.h>
wchar_t *
foo (void)
{
  char *__s = "zh_TW";
  wchar_t *pp;
  locale_t loc;
  union { char *__s; wchar_t *__w; } __u;

  loc = newlocale(1 << LC_ALL, __s, 0);
  __u.__s = nl_langinfo_l(_NL_WD_FMT, loc);
  pp = __u.__w;
  return pp;
}
int
main ()
{
  wchar_t *pp;
  pp = foo ();
  return 0;
}

Displaying the return value from the call to foo yields
(gdb) p ((wchar_t *)$ret0)[0]
$1 = 37

So, I think the problem is in nl_langinfo_l.

Dave


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31413

Reply via email to