Opened 11 years ago
Closed 5 years ago
#6815 closed Feature Requests (wontfix)
Compile time checking of format string (e.g. in printf)
Reported by: | Owned by: | James E. King, III | |
---|---|---|---|
Milestone: | To Be Determined | Component: | format |
Version: | Boost Development Trunk | Severity: | Not Applicable |
Keywords: | Cc: | d.starosud@… |
Description
It would be great to have possibility to check correspondence and correctness of format and arguments of printf function in compile time. This functionality would fill in the lack of expressive power of user-defined literals form C++11, I mean inability to use template-user-defined literal for character strings (e.g. "qwerty 123"_format). In attachment you can find my implementation of it. It would be really great if it or maybe better improved variant of it will be in boost.
Attachments (4)
Change History (8)
by , 11 years ago
Attachment: | templ_literal.h added |
---|
by , 11 years ago
by , 11 years ago
Attachment: | main.2.cpp added |
---|
comment:1 by , 11 years ago
comment:3 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 5 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
This implementation is incomplete so I am going to mark it as wontfix. Seems like a cool idea but it wouldn't support dynamically generated format specifications and doesn't support the complete syntax of boost format... unit tests should be used in consuming code to ensure no exceptions occur.
An interesting place to make a change like this could be in the gcc/clang static analyzers... if you build with "-Wformat" they can stop a build on a static format string that is malformed or when the wrong sized argument is given for a conversion specifier. Perhaps adding support for boost::format to that would be useful, but it still wouldn't take care of dynamically generated format specifications.
Sorry, I added two similar files.