This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/67957] New: gcc's printf attribute accepts %m as a format character
- From: "christos at zoulas dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 13 Oct 2015 15:16:56 +0000
- Subject: [Bug c/67957] New: gcc's printf attribute accepts %m as a format character
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67957
Bug ID: 67957
Summary: gcc's printf attribute accepts %m as a format
character
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: christos at zoulas dot com
Target Milestone: ---
According to TOG
(http://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html), %m is
not a legal formatting character for printf(3) like functions. Some
implementations (glibc) accept this formatting character as an extension and
expand it to the error string via strerror(3) that errno currently points to.
Most other c library implementations do not expand %m.
Attached is a patch that makes printf warn when %m is present and adds a
"syslog" attribute that accepts %m. I recognize that this is an incompatible
change, and I welcome suggestions how to do this in a less intrusive way.
I tried to mininize the size of the patch; there are better ways to do this,
but require more refactoring.