public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/50154] New: attribute printf and scanf should imply attribute nonnull @ 2011-08-22 16:29 bruno at clisp dot org 2011-08-22 16:35 ` [Bug c/50154] " bruno at clisp dot org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: bruno at clisp dot org @ 2011-08-22 16:29 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50154 Bug #: 50154 Summary: attribute printf and scanf should imply attribute nonnull Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: bruno@clisp.org Created attachment 25076 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25076 test case When a function is declared as taking a printf or scanf format string, gcc gives a warning when a format string with invalid syntax is passed. It should also give a warning when a NULL format string is passed. How to reproduce: Save the test case file as foo.c. $ gcc -Wformat=2 -c foo.c [no warning] $ gcc -Wformat=2 -c foo.c -DDECLARE_NONNULL foo.c: In function 'foo': foo.c:10:3: warning: null argument where non-null required (argument 3) [-Wnonnull] Rationale: 1) ISO C 99 specifies that the printf and scanf format strings must be "multibyte character sequences"; that excludes NULL. See ISO C 99 sections 7.19.6.1 paragraph 3 and 7.19.6.2 paragraph 3. 2) Passing NULL as first argument to printf crashes the program on FreeBSD, Solaris, and other platforms. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/50154] attribute printf and scanf should imply attribute nonnull 2011-08-22 16:29 [Bug c/50154] New: attribute printf and scanf should imply attribute nonnull bruno at clisp dot org @ 2011-08-22 16:35 ` bruno at clisp dot org 2011-08-24 21:17 ` pinskia at gcc dot gnu.org 2011-08-25 11:54 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: bruno at clisp dot org @ 2011-08-22 16:35 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50154 bruno at clisp dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #25076|0 |1 is obsolete| | --- Comment #1 from bruno at clisp dot org 2011-08-22 16:29:26 UTC --- Created attachment 25077 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25077 test case (corrected) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/50154] attribute printf and scanf should imply attribute nonnull 2011-08-22 16:29 [Bug c/50154] New: attribute printf and scanf should imply attribute nonnull bruno at clisp dot org 2011-08-22 16:35 ` [Bug c/50154] " bruno at clisp dot org @ 2011-08-24 21:17 ` pinskia at gcc dot gnu.org 2011-08-25 11:54 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2011-08-24 21:17 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50154 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Severity|normal |enhancement --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-08-24 21:15:37 UTC --- I think it is better if the person adds nonnull attribute themselves rather than GCC adding it with the printf format. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/50154] attribute printf and scanf should imply attribute nonnull 2011-08-22 16:29 [Bug c/50154] New: attribute printf and scanf should imply attribute nonnull bruno at clisp dot org 2011-08-22 16:35 ` [Bug c/50154] " bruno at clisp dot org 2011-08-24 21:17 ` pinskia at gcc dot gnu.org @ 2011-08-25 11:54 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: jakub at gcc dot gnu.org @ 2011-08-25 11:54 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50154 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |jakub at gcc dot gnu.org Resolution| |INVALID --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-08-25 11:13:59 UTC --- Yeah, I agree with that. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-25 11:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-22 16:29 [Bug c/50154] New: attribute printf and scanf should imply attribute nonnull bruno at clisp dot org 2011-08-22 16:35 ` [Bug c/50154] " bruno at clisp dot org 2011-08-24 21:17 ` pinskia at gcc dot gnu.org 2011-08-25 11:54 ` jakub at gcc dot gnu.org
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).