[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #64384] *printf() replacements break -Wformat
From: |
Pierre Ossman |
Subject: |
[bug #64384] *printf() replacements break -Wformat |
Date: |
Wed, 5 Jul 2023 10:21:11 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?64384>
Summary: *printf() replacements break -Wformat
Group: GNU gettext
Submitter: cendossm
Submitted: Wed 05 Jul 2023 02:21:09 PM UTC
Category: Build
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Wed 05 Jul 2023 02:21:09 PM UTC By: Pierre Ossman <cendossm>
If the replacements *printf() functions (e.g. libintl_printf()) are active,
then gcc correctly deduces that those are not the same as the standard
*printf() functions. As such, it doesn't apply the standard checks that are
enabled by -Wformat.
This is bad, since you lose all that type checking and fail to catch buggy
calls.
You can work around it by doing this:
#if defined(__GNUC__) && defined(printf)
extern int fprintf (FILE *, const char *, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int printf (const char *, ...)
__attribute__((__format__ (__printf__, 1, 2)));
extern int sprintf (char *, const char *, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int snprintf (char *, size_t, const char *, ...)
__attribute__((__format__ (__printf__, 3, 4)));
extern int asprintf (char **, const char *, ...)
__attribute__((__format__ (__printf__, 2, 3)));
#endif
#if defined(__GNUC__) && defined(wprintf)
extern int fwprintf (FILE *, const wchar_t *, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int wprintf (const wchar_t *, ...)
__attribute__((__format__ (__printf__, 1, 2)));
extern int swprintf (wchar_t *, size_t, const wchar_t *, ...)
__attribute__((__format__ (__printf__, 3, 4)));
#endif
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?64384>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug #64384] *printf() replacements break -Wformat,
Pierre Ossman <=