Describe the bug
Per [format.string.std]/7
… If the corresponding formatting argument is not of integral type
… an exception of type format_error is thrown.
When using a non-integral type as arg-id in std::format the code violates [format.fmt.string]/3 and is therefore ill-formed. The STL incorrectly accepts the format string, however, and throws an exception at run-time https://godbolt.org/z/b868c3M8z.
#include <format>
#include <iostream>
int main() {
try {
std::cout << std::format("{:*^{}}\n", 'a', 1.1);
} catch(...) {
std::cout << "die\n";
}
try {
std::cout << std::format("{:.{}}\n", "abc", 1.1);
} catch(...) {
std::cout << "die\n";
}
}
Describe the bug
Per [format.string.std]/7
When using a non-integral type as arg-id in
std::formatthe code violates [format.fmt.string]/3 and is therefore ill-formed. The STL incorrectly accepts the format string, however, and throws an exception at run-time https://godbolt.org/z/b868c3M8z.