public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "piannetta at kalrayinc dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug pch/112747] New: #pragma GCC diagnostic ignored "-Wstringop-overflow" has no effect in pre-compiled headers.
Date: Tue, 28 Nov 2023 16:15:02 +0000	[thread overview]
Message-ID: <bug-112747-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2023-11-28 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 16:15 piannetta at kalrayinc dot com [this message]
2023-11-28 17:12 ` [Bug pch/112747] " lhyatt at gcc dot gnu.org

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=bug-112747-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).