https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112747
Bug ID: 112747
Summary: #pragma GCC diagnostic ignored "-Wstringop-overflow"
has no effect in pre-compiled headers.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: pch
Assignee: unassigned at gcc dot gnu.org
Reporter: piannetta at kalrayinc dot com
Target Milestone: ---
==> t.c <==
#include "t.h"
extern char a[10];
int g ()
{
return f(a, 11, 1);
}
==> t.h <==
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
static char f (char *a, int idx, char v) { return a[idx] = v; }
#pragma GCC diagnostic pop
=====================================
$ gcc t.c -O2 -c
$ gcc t.h -O2
$ gcc t.c -O2
In function 'f',
inlined from 'g' at t.c:8:10:
t.h:3:58: warning: writing 1 byte into a region of size 0
[-Wstringop-overflow=]
t.c: In function 'g':
t.c:4:13: note: at offset 11 into destination object 'a' of size 10
=====================================
-Wstringop-overflow is not ignored as it ought to be when a pre-compiled header
exists. This cause the test
gcc/libstdc++-v3/testsuite/21_strings/basic_string/allocator/char/minimal.cc
from libstdc++v3 to fail.
I can reproduce the bug on gcc12, gcc13, gcc14 and trunk.