Open
Description
#include <format>
int main()
{
auto const str = std::format("{0}", -1);
}
If this mini-code is compiled with “AddressSanitizer” option, an undefined-behavior is detected.
The error only occurs with negative Integers.
Clang++-Version = 18
Option = -fsanitize=unsigned-integer-overflow
OS: Ubuntu 24.04 (64-bit)
example:
clang++-18 -fsanitize=unsigned-integer-overflow -std=c++20 format.cpp -o my_format
output:
runtime error: negation of 4294967295 cannot be represented in type 'make_unsigned_t' (aka 'unsigned int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/format:1099:12