wctrans_t and wctype_tAuthors: Jay Ghiron
Date: 2026-04-23
Submitted against: C23
Status: Open
Cross-references: 1035
The types wctrans_t and wctype_t are both scalar types which have
a value of zero mentioned, for example:
If
propertyidentifies a valid class of wide characters according to theLC_CTYPEcategory of the current locale, thewctypefunction returns a nonzero value that is valid as the second argument to theiswctypefunction; otherwise, it returns zero.
(C23 7.32.2.3.3 "The wctype function" paragraph 4.)
For integer types the meaning is obvious. For pointer types it is less obvious but the only answer that makes sense is that zero means null. For floating types, specifically those that support signed zeros or non-canonical representations of (positive, negative, or unsigned) zero the answer is less clear. To support uses like the following:
wctype_t c=wctype("example");
if(c){
/*...*/
}
It seems clear that anything which compares equal to zero should not be returned in success. But it is not as clear if negative zero or a non-canonical representation of (positive, negative, or unsigned) zero can be returned in failure.
Another issue with wctrans_t and wctype_t being floating types is
when those floating types support NaNs. If a signaling NaN can be
returned on success, then using the result could result in the
signaling NaN taking effect. It can occur even when copying the
value, see C23 F.3 paragraph 4. For quiet NaNs it would not have that
issue but it would still break comparisons between different values.
Though it is never actually specified that equality between different
wctrans_t values or that equality between different wctype_t
values requires them to work the same with towctrans and iswctype,
respectively.
For both wctrans and wctype, can they return negative zero or a
non-canonical representation of (positive, negative, or unsigned) zero
to indicate success?
If the answer to question one is that any value which compares equal
to zero cannot be returned on success, for both wctrans and wctype
can they return any value which compares equal to zero to indicate
failure?
For both wctrans and wctype, can they return signaling NaNs to
indicate success?
For both wctrans and wctype, can they return quiet NaNs to
indicate success?
Does equality between different wctrans_t values and equality
between different wctype_t values require that those values work the
same with towctrans and iswctype, respectively? For example,
would it be valid for an implementation to use padding bits in the
determination of towctrans and iswctype so that values which
compare equal function differently? For floating types non-canonical
representations and payloads of NaNs provide other means of
distinguishing values which compare equal. For pointer types it may
also be possible that pointers which compare equal can be
distinguished using provenance.
For both wctrans and wctype, are multiple invocations with the same
LC_CTYPE and argument required to return the same value?