From: Patrick Herbst <paherbst@gmail.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: how does -Wstringop-truncation work?
Date: Mon, 30 Jan 2023 17:35:39 -0500 [thread overview]
Message-ID: <CACMdL5+OX879q0Fhbuqd65P5_kL+zSwstKOX0FbYd_1-bFUWtg@mail.gmail.com> (raw)
I'm trying to understand how -Wstringop-truncation is generated.
I'm using the following example code with vanilla gcc 11.3 to generate
the warning
void append (char *buf, size_t bufsize)
{
strncat (buf, ".txt", 3);
}
I can get the warning to display if running
gcc -Wall -02
I can even get it to display if running
gcc -Wall -O1 -foptimize-strlen
but i cannot get it to display if not using optimization. I've even
tried manually adding all the -f options documented for -O1 to
understand what other flags might be needed to generate the warning.
I've had no success.
Is there a way to generate the -Wstringop-truncation warning without
optimization?
next reply other threads:[~2023-01-30 22:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 22:35 Patrick Herbst [this message]
2023-01-30 23:09 ` Segher Boessenkool
2023-01-30 23:16 ` Patrick Herbst
2023-01-30 23:36 ` Jonathan Wakely
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=CACMdL5+OX879q0Fhbuqd65P5_kL+zSwstKOX0FbYd_1-bFUWtg@mail.gmail.com \
--to=paherbst@gmail.com \
--cc=gcc-help@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).