public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* how does -Wstringop-truncation work?
@ 2023-01-30 22:35 Patrick Herbst
  2023-01-30 23:09 ` Segher Boessenkool
  2023-01-30 23:36 ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick Herbst @ 2023-01-30 22:35 UTC (permalink / raw)
  To: gcc-help

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-30 23:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 22:35 how does -Wstringop-truncation work? Patrick Herbst
2023-01-30 23:09 ` Segher Boessenkool
2023-01-30 23:16   ` Patrick Herbst
2023-01-30 23:36 ` Jonathan Wakely

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).