[PATCH] libstdc++: Make __from_chars_alnum_to_val conversion explicit
Marco Falke
falke.marco@gmail.com
Mon Jul 18 10:10:31 GMT 2022
(in reply to https://gcc.gnu.org/pipermail/gcc-patches/2022-July/598412.html,
adding libstdc++ to CC, with the same patch attached again)
To clarify, this is not a fix for a user-facing issue of gcc or a fix
for UB. It is just a minor UX improvement for developers that use the
clang integer sanitizer to detect implicit int conversions.
To reproduce:
$ cat 1.cpp
#include <charconv>
int main() {
const auto a{"-1"};
unsigned b{};
std::from_chars(a, a + 2, b);
}
$ clang++ -fsanitize=integer -std=c++17 1.cpp -o exe && ./exe
/usr/bin/../lib64/gcc/x86_64-s
use-linux/12/../../../../include/c++/12/charconv:439:9:
runtime error: implicit conversion from type 'int' of value -3
(32-bit, signed) to type 'unsigned char' changed the value to 253
(8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/usr/bin/../lib64/gcc/x86_64-suse-linux/12/../../../../include/c++/12/charconv:439:9
Best,
Marco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libstdc-Make-__from_chars_alnum_to_val-conversion-ex.patch
Type: text/x-patch
Size: 1244 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20220718/bf36fa46/attachment.bin>
More information about the Libstdc++
mailing list