From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Capture warnings when writing to the index cache
Date: Wed, 27 Mar 2024 10:39:18 -0400 [thread overview]
Message-ID: <1a9338d3-81a5-4e95-8823-6613781c323c@simark.ca> (raw)
In-Reply-To: <87o7azbycz.fsf@tromey.com>
On 2024-03-27 09:25, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>
> Simon> My interpretation of this is that we bind a function marked with
> Simon> `ATTRIBUTE_PRINTF (2,0)` (deferred_warnings::operator()) to a function
> Simon> view that doesn't convey the attribute. So I guess the compiler is
> Simon> telling us that whenever the function view is invoked, there won't be a
> Simon> format string check, and that's dangerous.
>
> Simon> I didn't find a good fix that :(.
>
> Please try the appended.
>
> thanks,
> Tom
>
> commit 8be8061ea5d0ec37289070f16717d3d0aa0c93af
> Author: Tom Tromey <tromey@adacore.com>
> Date: Wed Mar 27 07:21:56 2024 -0600
>
> patch
>
> diff --git a/gdb/utils.h b/gdb/utils.h
> index d7db1d84e2f..875a2583179 100644
> --- a/gdb/utils.h
> +++ b/gdb/utils.h
> @@ -444,10 +444,18 @@ struct deferred_warnings
> hook; see scoped_restore_warning_hook. Note that no locking is
> done, so users have to be careful to only install this into a
> single thread at a time. */
> - void operator() (const char *format, va_list args) ATTRIBUTE_PRINTF (2, 0)
> + void operator() (const char *format, va_list args)
> {
> string_file msg (m_can_style);
> + /* Clang warns if we add ATTRIBUTE_PRINTF to this method (because
> + the function-view wrapper doesn't also have the attribute), but
> + then warns again if we remove it, because this vprintf call
> + does not use a literal format string. So, suppress the
> + warnings here. */
> + DIAGNOSTIC_PUSH
> + DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
> msg.vprintf (format, args);
> + DIAGNOSTIC_POP
> m_warnings.emplace_back (std::move (msg));
> }
>
It builds fine with that patch.
Thanks,
Simon
next prev parent reply other threads:[~2024-03-27 14:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 14:40 Tom Tromey
2024-03-26 15:49 ` Tom Tromey
2024-03-27 3:08 ` Simon Marchi
2024-03-27 13:25 ` Tom Tromey
2024-03-27 14:39 ` Simon Marchi [this message]
2024-04-08 4:23 ` Simon Marchi
2024-04-08 12:59 ` Tom Tromey
2024-04-09 1:33 ` Simon Marchi
2024-04-09 15:20 ` Tom Tromey
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=1a9338d3-81a5-4e95-8823-6613781c323c@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/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