https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108939
--- Comment #2 from Anton Nikolaevsky <bezkrovatki at gmail dot com> ---
Indeed, with the sample code that I've originally reported the presence of the
flag -std=xxx does not matter. The fact is I started from the following a bit
more complex code:
====
#include <string.h>
#include <stdio.h>
#define LEN 32
int main(int argc, char* argv[])
{
char dest[LEN];
char src[LEN];
strcpy(src, argv[0]);
strncpy(dest, src, LEN);
dest[LEN-1]=0;
printf("%s\n", dest);
return 0;
}
====
With the sample above GCC 10 and 11 generate the warning when the flag
-std=c++11 is used and the warning is not generated with -std=gnu++11.
Tested here https://godbolt.org/z/vPYf8nsEv