public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way @ 2023-06-20 15:43 roland.illig at gmx dot de 2023-06-20 16:34 ` [Bug c/110322] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: roland.illig at gmx dot de @ 2023-06-20 15:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 Bug ID: 110322 Summary: Be more helpful when a varargs function is called in a wrong way Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: roland.illig at gmx dot de Target Milestone: --- ~~~c #include <stdarg.h> #include <stdio.h> static void __attribute__((__format__(__printf__, 1, 2))) my_printf(const char *fmt, ...) { va_list ap; va_start(ap, fmt); fprintf(stderr, fmt, ap); va_end(ap); } int main(int argc, char **argv) { my_printf("%d", 4); my_printf("%.*s\n", 5, "hello, world"); return 0; } ~~~ In the above program, I am accidentally trying to call fprintf with a va_list, instead of the correct vfprintf. GCC warns: sl.c:10:2: error: format not a string literal, argument types not checked [-Werror=format-nonliteral] 10 | fprintf(stderr, fmt, ap); | ^~~~~~~ In this situation, where my only mistake was to forget the 'v' from the function name, GCC should not complain that the format string is not a string literal, but rather that I'm calling the wrong function. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110322] Be more helpful when a varargs function is called in a wrong way 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de @ 2023-06-20 16:34 ` pinskia at gcc dot gnu.org 2023-06-20 16:34 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-20 16:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |87403 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87403 [Bug 87403] [Meta-bug] Issues that suggest a new warning ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110322] Be more helpful when a varargs function is called in a wrong way 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de 2023-06-20 16:34 ` [Bug c/110322] " pinskia at gcc dot gnu.org @ 2023-06-20 16:34 ` pinskia at gcc dot gnu.org 2023-06-20 16:35 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-20 16:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-06-20 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- . ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110322] Be more helpful when a varargs function is called in a wrong way 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de 2023-06-20 16:34 ` [Bug c/110322] " pinskia at gcc dot gnu.org 2023-06-20 16:34 ` pinskia at gcc dot gnu.org @ 2023-06-20 16:35 ` pinskia at gcc dot gnu.org 2023-06-21 6:35 ` egallager at gcc dot gnu.org 2023-06-21 6:58 ` xry111 at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-20 16:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note -Wformat-nonliteral is not enabled by default either (though IIRC Debian and Ubuntu turn it on by default). ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110322] Be more helpful when a varargs function is called in a wrong way 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de ` (2 preceding siblings ...) 2023-06-20 16:35 ` pinskia at gcc dot gnu.org @ 2023-06-21 6:35 ` egallager at gcc dot gnu.org 2023-06-21 6:58 ` xry111 at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: egallager at gcc dot gnu.org @ 2023-06-21 6:35 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=28492 CC| |egallager at gcc dot gnu.org --- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> --- kinda related: bug 28492 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/110322] Be more helpful when a varargs function is called in a wrong way 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de ` (3 preceding siblings ...) 2023-06-21 6:35 ` egallager at gcc dot gnu.org @ 2023-06-21 6:58 ` xry111 at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: xry111 at gcc dot gnu.org @ 2023-06-21 6:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110322 Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org --- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > Note -Wformat-nonliteral is not enabled by default either (though IIRC > Debian and Ubuntu turn it on by default). I guess we should make the case "casting a non-char pointer implicitly to the format string" default. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-21 6:58 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-06-20 15:43 [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way roland.illig at gmx dot de 2023-06-20 16:34 ` [Bug c/110322] " pinskia at gcc dot gnu.org 2023-06-20 16:34 ` pinskia at gcc dot gnu.org 2023-06-20 16:35 ` pinskia at gcc dot gnu.org 2023-06-21 6:35 ` egallager at gcc dot gnu.org 2023-06-21 6:58 ` xry111 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).