Skip to content

Commit f3a22d4

Browse files
use cpp::is_signed_v && update comment
1 parent 4d7a8b1 commit f3a22d4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

libc/src/__support/wctype_utils.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ namespace internal {
2828
LIBC_INLINE cpp::optional<int> wctob(wint_t c) {
2929
// This needs to be translated to EOF at the callsite. This is to avoid
3030
// including stdio.h in this file.
31-
// The standard states that wint_t may either be an alias of wchar_t or
32-
// an alias of an integer type where different platforms define this type with
33-
// different signedness, so we need to keep the c < 0 check, hence the
34-
// pragmas.
35-
#pragma GCC diagnostic push
36-
#pragma GCC diagnostic ignored "-Wtype-limits"
37-
if (c > 127 || c < 0)
31+
if (c > 127)
3832
return cpp::nullopt;
39-
#pragma GCC diagnostic pop
33+
// The standard states that wint_t may either be an alias of wchar_t or
34+
// an alias of an integer type, different platforms define this type with
35+
// different signedness, so we may need the c < 0 check.
36+
if constexpr (cpp::is_signed_v<wint_t>)
37+
if (c < 0)
38+
return cpp::nullopt;
4039
return static_cast<int>(c);
4140
}
4241

0 commit comments

Comments
 (0)