how does -Wstringop-truncation work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux