Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Noob <root@127.0.0.1> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: A printf question. |
| Date | 2015-10-25 23:02 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <n0jjed$9gp$1@dont-email.me> (permalink) |
| References | <mvj3b8$i7h$1@dont-email.me> <mvjlns$6ih$1@dont-email.me> <mvkg7v$v5d$1@speranza.aioe.org> |
On 14/10/2015 04:55, glen herrmannsfeldt wrote: > James Kuyper <jameskuyper@verizon.net> wrote: > > (snip on printf with one argument) > >> <stdio.h> brings in a prototype declaration of printf() like the following: >> >> int printf(const char * restrict format, ...); (7.21.6.3p1) >> >> Such a prototype requires that: >> 1. The function be called with at least one argument. >> printf(message) meets that requirement >> 2. The type of that argument must be convertible to "const char*". >> The type of message is "const char*", and therefore trivially convertible. > > With compilers generating more and more warnings, possibly for things > that are actually correct, I would not be surprised to see a warning > for a single non-constant argument. And it is indeed possible to request such a warning from gcc: (Though it wouldn't fire in the OP's example) > -Wformat-security: If -Wformat is specified, also warn about uses of > format functions that represent possible security problems. At > present, this warns about calls to printf and scanf functions where > the format string is not a string literal and there are no format > arguments, as in printf(foo). This may be a security hole if the > format string came from untrusted input and contains ā%nā. (This is > currently a subset of what -Wformat-nonliteral warns about, but in > future warnings may be added to -Wformat-security that are not > included in -Wformat-nonliteral.) https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html Regards.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
A printf question. MehdiAmini <atorrses@gmail.com> - 2015-10-13 14:09 +0000
Re: A printf question. Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-13 10:46 -0400
Re: A printf question. Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-10-13 09:19 -0700
Re: A printf question. Keith Thompson <kst-u@mib.org> - 2015-10-13 10:45 -0700
Re: A printf question. David Brown <david.brown@hesbynett.no> - 2015-10-13 23:15 +0200
Re: A printf question. James Kuyper <jameskuyper@verizon.net> - 2015-10-13 15:25 -0400
Re: A printf question. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-10-14 02:55 +0000
Re: A printf question. James Kuyper <jameskuyper@verizon.net> - 2015-10-13 23:12 -0400
Re: A printf question. supercat@casperkitty.com - 2015-10-14 06:34 -0700
Re: A printf question. Keith Thompson <kst-u@mib.org> - 2015-10-14 10:26 -0700
Re: A printf question. MehdiAmini <atorrses@gmail.com> - 2015-10-15 14:06 +0000
Re: A printf question. James Kuyper <jameskuyper@verizon.net> - 2015-10-15 10:26 -0400
Re: A printf question. Noob <root@127.0.0.1> - 2015-10-25 23:02 +0100
csiph-web