public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* syslog: ISO C does not support the ‘%m’ gnu_printf format
@ 2022-01-25  4:08 Kris Andersen
  2022-01-25  7:05 ` Ankur Saini
  0 siblings, 1 reply; 2+ messages in thread
From: Kris Andersen @ 2022-01-25  4:08 UTC (permalink / raw)
  To: gcc

The %m format specifier is a documented feature of syslog, but gcc gives a
warning when -Wpedantic is used. Is this a bug?

For example, the program:

#include <syslog.h>
int main(void)
{
    syslog(LOG_ERR, "%m");
    return 0;
}

gives:
warning: ISO C does not support the ‘%m’ gnu_printf format [-Wformat=]

when compiled[1] with
gcc -Wall -Wextra -Wpedantic -o test test.c

The man page for syslog(3) states that %m is supported: "the two-character
sequence %m will be replaced by the error message string strerror(errno)."

Submitting a bug report for this feels like arguing that the answer in the
back of the book is wrong (...rarely the right move). What am I missing
here?

Thanks in advance,

  Kris

[1]: gcc (GCC) 11.2.1 20211203 on Linux version 5.15.16-200.fc35.x86_64
(Fedora v35)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: syslog: ISO C does not support the ‘%m’ gnu_printf format
  2022-01-25  4:08 syslog: ISO C does not support the ‘%m’ gnu_printf format Kris Andersen
@ 2022-01-25  7:05 ` Ankur Saini
  0 siblings, 0 replies; 2+ messages in thread
From: Ankur Saini @ 2022-01-25  7:05 UTC (permalink / raw)
  To: Kris Andersen; +Cc: gcc



> On 25-Jan-2022, at 9:38 AM, Kris Andersen via Gcc <gcc@gcc.gnu.org> wrote:
> 
> The %m format specifier is a documented feature of syslog, but gcc gives a
> warning when -Wpedantic is used. Is this a bug?
> 
> For example, the program:
> 
> #include <syslog.h>
> int main(void)
> {
>    syslog(LOG_ERR, "%m");
>    return 0;
> }
> 
> gives:
> warning: ISO C does not support the ‘%m’ gnu_printf format [-Wformat=]

I think, the compiler is correct by complaining about it when strict
warnings are enabled.

according to GNU documentation
(http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html)

“ The ‘%m’ conversion is a GNU C Library extension “

> 
> when compiled[1] with
> gcc -Wall -Wextra -Wpedantic -o test test.c
> 
> The man page for syslog(3) states that %m is supported: "the two-character
> sequence %m will be replaced by the error message string strerror(errno)."
> 
> Submitting a bug report for this feels like arguing that the answer in the
> back of the book is wrong (...rarely the right move). What am I missing
> here?

FWIW, A bug report requesting support for __format__ attribute for
syslog is already filed as bug 15338 (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15338 )

Thanks
- Ankur

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-25  7:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25  4:08 syslog: ISO C does not support the ‘%m’ gnu_printf format Kris Andersen
2022-01-25  7:05 ` Ankur Saini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).