public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "egall at gwmail dot gwu.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/47781] warnings from custom printf format specifiers
Date: Mon, 21 Sep 2015 19:16:00 -0000	[thread overview]
Message-ID: <bug-47781-4-39mkUKCyXN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-47781-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781

Eric Gallager <egall at gwmail dot gwu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egall at gwmail dot gwu.edu

--- Comment #15 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Tom Tromey from comment #11)
> ...I wanted to point out that requiring a plugin for the simple cases is
> significantly harder for users than some in-source extension mechanism.
> 
> E.g., firefox has a logging printf that accepts "%hs" to print char16_t*
> strings.  This extension means that printf checking can't be used here.
> Requiring a plugin to deal with this situation would also be difficult.
> However letting one write __attribute__((printf, 1, 2, "hs", char16_t*))
> would solve this nicely.
> 
> I suppose I think that a format-for-a-specific-type is the most common
> kind of extension and so may deserve special treatment.

Wow, this is pretty much the same syntax I imagined when coming across this
issue independently! Except in my idea, I changed the name of the format
attribute to "printf-extended", to make it more obvious what the extra
arguments are. The case where I came across it was in trying to build a forked
old version bfd with -Wsuggest-attribute=format and -Wformat=2, where I was
unable to attach a format attribute to the bfd_error_handler_type declaration.
This is because _bfd_default_error_handler is extended to accept 2 new format
specifiers: %A, which takes args of type asection*, and %B, which takes args of
type bfd*. Using an attribute as proposed above, it'd be simple to just write
something like,

__attribute__((format(printf-extended, 1, 2, "A", asection*, "B", bfd*)))

Although checking the commentary on newer mainline versions of the
_bfd_default_error_handler function, it looks like it does some additional
weird stuff with the argument order, but still, support for extending the
format attribute like this would still be a good start!


  parent reply	other threads:[~2015-09-21 19:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 11:55 [Bug c/47781] New: " mark-gcc at glines dot org
2011-02-17 11:58 ` [Bug c/47781] " manu at gcc dot gnu.org
2011-02-17 12:00 ` mark-gcc at glines dot org
2011-02-17 12:14 ` mark-gcc at glines dot org
2011-02-17 18:38 ` joseph at codesourcery dot com
2013-09-23 21:54 ` pinskia at gcc dot gnu.org
2013-09-23 21:55 ` pinskia at gcc dot gnu.org
2013-09-23 21:57 ` pinskia at gcc dot gnu.org
2014-08-21 17:07 ` joseph at codesourcery dot com
2014-08-21 17:54 ` philipp_subx@redfish-solutions.com
2015-01-29 16:42 ` tromey at gcc dot gnu.org
2015-01-29 21:55 ` joseph at codesourcery dot com
2015-02-04 17:38 ` tromey at gcc dot gnu.org
2015-02-04 18:44 ` manu at gcc dot gnu.org
2015-09-21 19:16 ` egall at gwmail dot gwu.edu [this message]
2020-12-13 15:48 ` dcrocker at eschertech dot com
2020-12-14 14:10 ` tromey at gcc dot gnu.org
2021-12-06 17:47 ` grant.b.edwards at gmail dot com
2021-12-06 22:48 ` joseph at codesourcery dot com
2023-01-18 11:03 ` jan@swi-prolog.org
2023-01-18 12:11 ` manu at gcc dot gnu.org
2023-01-18 17:40 ` joseph at codesourcery dot com
2023-01-18 17:46 ` manu at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-47781-4-39mkUKCyXN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).