File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -28,15 +28,14 @@ namespace internal {
28
28
LIBC_INLINE cpp::optional<int > wctob (wint_t c) {
29
29
// This needs to be translated to EOF at the callsite. This is to avoid
30
30
// 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 )
38
32
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;
40
39
return static_cast <int >(c);
41
40
}
42
41
You can’t perform that action at this time.
0 commit comments