Skip to content

03. Why not format string?

cqwrteur edited this page Apr 28, 2024 · 4 revisions

The use of format strings was a historical mistake. Originally designed in the 1970s by AT&T Labs, format strings aimed to avoid adding excessive complexity to the language and prevent language dependencies on I/O facilities. However, format strings are vulnerable to attacks, and there’s no straightforward fix. Even restricting format strings to compile-time only doesn’t fully address the issue (macros can still pose hazards and introduce localization challenges).

One could argue that format strings remain problematic even for localization, as they can be represented purely in binary form. C++20’s std::format lacks features essential for tools like GNU gettext, and finding an elegant solution without increasing complexity is challenging.

In this library, you will not encounter format strings; they are unnecessary.

Clone this wiki locally