This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] g++.dg/cpp1y/pr58708.C wchar_t size
- From: Mike Stump <mikestump at comcast dot net>
- To: David Edelsohn <dje dot gcc at gmail dot com>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 17 Nov 2015 15:39:52 -0800
- Subject: Re: [PATCH] g++.dg/cpp1y/pr58708.C wchar_t size
- Authentication-results: sourceware.org; auth=none
- References: <CAGWvnym6qLBn7=kpHdwnCNSDPSX5Jk4=wjvtH822hPey_P9Hbg at mail dot gmail dot com> <CAH6eHdSZJr0NwG=rvJeidgBtV4m8L3DuUwfZ8RJBQH+OVCBzzg at mail dot gmail dot com> <CAGWvny=isqxyzCn+q1VoBGRA8WyqN9Ou_ErFq=d3VbWXB51LwA at mail dot gmail dot com>
On Nov 17, 2015, at 8:50 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
>
> Thanks for the pointer. How about the following?
Ok.
sizeof (*wfoo) or sizeof (wchar_t) or some such might be even more portable.
>
> Thanks, David
>
>
> Index: pr58708.C
> ===================================================================
> --- pr58708.C (revision 230463)
> +++ pr58708.C (working copy)
> @@ -43,7 +43,11 @@
> if (foo.chars[1] != 98) __builtin_abort();
> if (foo.chars[2] != 99) __builtin_abort();
>
> - auto wfoo = L"\x01020304\x05060708"_foo;
> +#if __SIZEOF_WCHAR_T__ == 2
> + auto wfoo = L"\x0102\x0304"_foo;
> +#else
> + auto wfoo = L"\x01020304\x05060708"_foo;
> +#endif
> if (is_same<decltype(wfoo)::char_type, wchar_t>::value != true)
> __builtin_abort();
> if (sizeof(wfoo.chars)/sizeof(wchar_t) != 2) __builtin_abort();
> if (wfoo.chars[0] != 16909060) __builtin_abort();