[Bug c++/50593] New: improve __attribute__((format(printf)))
b.r.longbons at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Oct 2 21:58:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50593
Bug #: 50593
Summary: improve __attribute__((format(printf)))
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: b.r.longbons@gmail.com
Created attachment 25398
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25398
8 tests
There are a number of cases where the compiler should be able to use a constant
string to check the arguments of a printf-like function.
Expected Result:
GCC always warns about format argument errors, when it can.
Actual Result:
GCC only warns in a couple of cases.
In particular, note:
* const char[] works in C but not C++.
* Directly using the result of a constexpr function doesn't work, but assigning
it to a variable does. (This is fortunate, because it allowed me to write the
most awesome code ever, a safe wrapper that allows passing e.g. a std::string
to printf!)
Versions tested:
All tests: 4.6.1 (gentoo), r179098 from branch 4.6, and trunk sometime near
that.
Tests 1,2,6,7,8 (without constexpr): 4.5.3, 4.4.6, 4.3.6 (gentoo)
Tests 1,2 (C++98): 4.2.4 (gentoo)
Tests 1,2 in C: all mentioned versions.
More information about the Gcc-bugs
mailing list