From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BF193858D1E; Tue, 20 Jun 2023 15:43:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BF193858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687275793; bh=LH8SJYAZVkLTkSjqkZ3L4WQW6Ane6+501UY9K5zppgo=; h=From:To:Subject:Date:From; b=Dsu4lTmbe0SbwfUVkL8ljxSjTweAsBI0ifPPSyitnmqQ676tVen9U6H0eZOgxIjyo QlE8rNlvwsjk4eLzJKR9HL+1d+YtxfwUc9aJOXLN+WxZ5pEn2hcGwF4Srisb6nYKsZ LqLuH56n9YBGHzXZuOXhfAzdnUIVyPc2qCKoAVrA= From: "roland.illig at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110322] New: Be more helpful when a varargs function is called in a wrong way Date: Tue, 20 Jun 2023 15:43:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: roland.illig at gmx dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110322 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 #include 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_li= st, instead of the correct vfprintf. GCC warns: sl.c:10:2: error: format not a string literal, argument types not checked [-Werror=3Dformat-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 stri= ng literal, but rather that I'm calling the wrong function.=