--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAMO7KM_XoKsvopAZ-8n%3D4g9-BESTpk%3Dz4Wj8a8%2ByFCHS2TYaVg%40mail.gmail.com.
This is a signed conversion. With prevent_unsafe_narrowing, you'd get a compiler error IIUC. So that is probably what we should be relying on.
PK
Thanks! Yeah I'm not too sure on the details. Seems like isalpha takes an int (!!!), but it's UB if you pass something that is "not representable as unsigned char and is not equal to EOF." I believe u16string and u32string variants use signed chars too, so they will be UB?
Also isalpha has some complexities around locales, so I'm not sure if it's the right default choice regardless of signed conversions?
On Wed, Sep 7, 2022 at 2:40 AM Peter Kasting <pkas...@google.com> wrote:I'd be supportive of ensuring we have sufficient replacements in base/, then PRESUBMIT-banning these functions.Sounds good, I'm glad! Should I file a bug for this?
On Tue, Sep 6, 2022 at 6:57 PM Darren Shen <sh...@chromium.org> wrote:Thanks! Yeah I'm not too sure on the details. Seems like isalpha takes an int (!!!), but it's UB if you pass something that is "not representable as unsigned char and is not equal to EOF." I believe u16string and u32string variants use signed chars too, so they will be UB?u16string and u32string use char16_t and char32_t, which are unsigned. But icu::UnicodeString uses icu::UChar32, which is signed.
Also isalpha has some complexities around locales, so I'm not sure if it's the right default choice regardless of signed conversions?It's usually not the right choice, no, since it relies on the C locale, while we want to make decisions based on the Chromium UI language.On Wed, Sep 7, 2022 at 2:40 AM Peter Kasting <pkas...@google.com> wrote:I'd be supportive of ensuring we have sufficient replacements in base/, then PRESUBMIT-banning these functions.Sounds good, I'm glad! Should I file a bug for this?A bug is probably a good place for further discussion, sure.PK
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFD-oWCMU43X1-hTyYZgPTfB%2B0CB4w8J_47MQiSFwU%2BS0w%40mail.gmail.com.