[libcxx-commits] [PATCH] D122532: Do not use non-POSIX strtoll_l and strtoull_l

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 30 03:33:39 PDT 2022


Mordante added a subscriber: howard.hinnant.
Mordante added a comment.

Good to hear it now works on your platform!

I did some digging and I'm not sure whether it's safe to switch to `stroull` even when the Standard requires this.
`__num_get_unsigned_integral` is used in Stage 3 of `do_get` http://eel.is/c++draft/facet.num.get.virtuals#3.3 
This function uses the locale of the `ios_base`, which may differ from the global locale.

Based C17's FDIS https://web.archive.org/web/20181230041359/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf
7.22.1.4 The strtol, strtoll, strtoul, and strtoull functions
`ยง 6 In other than the "C" locale, additional locale-specific subject sequence forms may be accepted.`

So this leaves room for `strtoull` to accept its input in a locale specific way.

So before changing this I like to make sure this is really safe. I don't know how well our test coverage is this area is, but my experience is that our locale validation isn't as extensive as it should be. (For example, last weekend I discovered we don't test `time_put`'s alternative digits with a locale that uses alternative digits. I'm working on a patch to improve this.)

Maybe @howard.hinnant can shed more light on why the code uses `strtoll_l`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122532/new/

https://reviews.llvm.org/D122532



More information about the libcxx-commits mailing list