Subject: bin/6205: gcc -pedantic complains about %m in syslog format strings
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 09/27/1998 08:00:02
>Number:         6205
>Category:       bin
>Synopsis:       gcc -pedantic complains about %m in syslog format strings
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 27 02:05:01 1998
>Last-Modified:
>Originator:     Dave Sainty
>Organization:
Dynamic Technology Services and Products Ltd
>Release:        sup as of 23/9/98
>Environment:
>Description:
	gcc -pedantic complains about %m in syslog format strings
>How-To-Repeat:

cat >| ex.c <<EOF
#include <syslog.h>
int main() {
syslog(LOG_ERR, "%m");
return 0;
}
EOF
gcc -Wall -pedantic ex.c
ex.c: In function `main':
ex.c:3: warning: ANSI C does not support the `m' format

	As far as I can tell, everything that supports syslog() supports %m,
	so its usage should not be warned about.  It "should" be as easy as
	adding a new format description to gcc to describe syslog slightly
	differently, but unfortunately the standards description of the format
	character is not part of the format description, it's hard coded
	(yuck).

>Fix:

This fix has the side-effect of not warning about %m usage in printf either.
I don't know if NetBSDs printf even supports %m, the man page doesn't mention
it.

To fix this properly this code should probably be significantly reworked so
ANSI conformance is part of the format description.

--- src/gnu/dist/gcc/c-common.c.orig    Tue Aug 25 23:05:51 1998
+++ src/gnu/dist/gcc/c-common.c Sun Sep 27 19:30:41 1998
@@ -1680,7 +1680,7 @@
        }
       /* The m, C, and S formats are GNU extensions.  */
       if (pedantic && info->format_type != strftime_format_type
-         && (format_char == 'm' || format_char == 'C' || format_char == 'S'))
+         && (format_char == 'C' || format_char == 'S'))
        warning ("ANSI C does not support the `%c' format", format_char);
       /* ??? The a and A formats are C9X extensions, and should be allowed
         when a C9X option is added.  */
>Audit-Trail:
>Unformatted:
System: NetBSD tequila.dave.dtsp.co.nz 1.3G NetBSD 1.3G (TEQUILA) #1: Thu Aug 20 00:13:30 NZST 1998 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userC/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386