* wchar_t does not satisfy std::integral concept on DJGPP MSDOS toolchains
@ 2020-10-31 22:21 sotrdg sotrdg
2020-11-01 10:03 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: sotrdg sotrdg @ 2020-10-31 22:21 UTC (permalink / raw)
To: libstdc++
Please fix it.
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: wchar_t does not satisfy std::integral concept on DJGPP MSDOS toolchains
2020-10-31 22:21 wchar_t does not satisfy std::integral concept on DJGPP MSDOS toolchains sotrdg sotrdg
@ 2020-11-01 10:03 ` Jonathan Wakely
2020-11-01 11:43 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2020-11-01 10:03 UTC (permalink / raw)
To: sotrdg sotrdg; +Cc: libstdc++
On 31/10/20 22:21 +0000, sotrdg sotrdg via Libstdc++ wrote:
>Please fix it.
It's determined by the result of the GLIBCXX_ENABLE_WCHAR_T checks in
libstdc++-v3/acinclude.m4
djgpp must be missing some wchar_t library support.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: wchar_t does not satisfy std::integral concept on DJGPP MSDOS toolchains
2020-11-01 10:03 ` Jonathan Wakely
@ 2020-11-01 11:43 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2020-11-01 11:43 UTC (permalink / raw)
To: sotrdg sotrdg; +Cc: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 712 bytes --]
On 01/11/20 10:03 +0000, Jonathan Wakely wrote:
>On 31/10/20 22:21 +0000, sotrdg sotrdg via Libstdc++ wrote:
>>Please fix it.
>
>It's determined by the result of the GLIBCXX_ENABLE_WCHAR_T checks in
>libstdc++-v3/acinclude.m4
>
>djgpp must be missing some wchar_t library support.
This patch makes some of the type traits work without libc support for
wchar_t. This is necessary for freestanding anyway, because we almost
certainly don't have <wchar.h> etc. in freestanding, but the standard
still requires wchar_t to exist and be an integral type.
Tested powerpc64le-linux and (briefly) avr. For avr the value of
is_integral<wchar_t> is now true, and make_signed/unsigned work for
wchar_t.
Pushed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3465 bytes --]
commit 29e418485848c4a6943d8561cd8fb0b1abf14015
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sun Nov 1 10:56:36 2020
libstdc++: Define type traits for wchar_t even when libc support missing
This meets the requirement that std::is_integral_v<wchar_t> is true,
even when full library support for wchar_t via specializations of
char_traits etc. is not provided. This is done by checking
__WCHAR_TYPE__ to see if the compiler knows about the type, rather than
checking the library's own _GLIBCXX_USE_WCHAR_T autoconf macro.
This assumes that the C++ compiler correctly defines wchar_t as a
distinct type, not a typedef for one of the other integeral types. This
is always true for G++ and should be true for any supported non-GNU
compilers.
Similarly, the std::make_unsigned and std::make_signed traits and the
internal helpers std::__is_integer and std::__is_char are also changed
to depend on the same macro.
libstdc++-v3/ChangeLog:
* include/std/type_traits (is_integral<wchar_t>)
(make_unsigned<wchar_t>, make_signed<wchar_t>): Define based
on #ifdef __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T.
* include/bits/cpp_type_traits.h (__is_integer<wchar_t>)
(__is_char<wchar_t>): Likewise.
diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h
index b48d1adc63c9..433a2d7d35bc 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -162,7 +162,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef __true_type __type;
};
-# ifdef _GLIBCXX_USE_WCHAR_T
+# ifdef __WCHAR_TYPE__
template<>
struct __is_integer<wchar_t>
{
@@ -363,7 +363,7 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
typedef __true_type __type;
};
-#ifdef _GLIBCXX_USE_WCHAR_T
+#ifdef __WCHAR_TYPE__
template<>
struct __is_char<wchar_t>
{
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index e9a0f55dd4a8..34e068b59523 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -269,7 +269,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __is_integral_helper<unsigned char>
: public true_type { };
-#ifdef _GLIBCXX_USE_WCHAR_T
+ // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work)
+ // even when libc doesn't provide working <wchar.h> and related functions,
+ // so check __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T.
+#ifdef __WCHAR_TYPE__
template<>
struct __is_integral_helper<wchar_t>
: public true_type { };
@@ -1742,7 +1745,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// neither signed integer types nor unsigned integer types, so must be
// transformed to the unsigned integer type with the smallest rank.
// Use the partial specialization for enumeration types to do that.
-#if defined(_GLIBCXX_USE_WCHAR_T)
+#ifdef __WCHAR_TYPE__
template<>
struct __make_unsigned<wchar_t>
{
@@ -1868,7 +1871,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// signed integer types nor unsigned integer types, so must be
// transformed to the signed integer type with the smallest rank.
// Use the partial specialization for enumeration types to do that.
-#if defined(_GLIBCXX_USE_WCHAR_T)
+#if defined(__WCHAR_TYPE__)
template<>
struct __make_signed<wchar_t>
{
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-01 11:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 22:21 wchar_t does not satisfy std::integral concept on DJGPP MSDOS toolchains sotrdg sotrdg
2020-11-01 10:03 ` Jonathan Wakely
2020-11-01 11:43 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).