-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!formatC++20/23 formatC++20/23 format
Description
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";
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixedSomething works now, yay!Something works now, yay!formatC++20/23 formatC++20/23 format