Bug 107936 - #pragma GCC diagnostic ignored vs. LTO
Summary: #pragma GCC diagnostic ignored vs. LTO
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 12.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, lto
Depends on: 80922
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-30 16:01 UTC by Jakub Jelinek
Modified: 2023-09-28 06:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-11-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2022-11-30 16:01:29 UTC
rh1948567-1.c:
void foo (char x[2]);

int
main ()
{
  char x[2];
#pragma GCC diagnostic ignored "-Wstringop-overflow"
  foo (x + 1);
}
rh1948567-2.c:
void
foo (char x[2])
{
  asm volatile ("" : : "r" (&x[0]) : "memory");
}
gcc -W -Wall -flto -o rh1948567{,-1.c,-2.c}
rh1948567-1.c: In function ‘main’:
rh1948567-1.c:8:3: warning: ‘foo’ accessing 2 bytes in a region of size 1 [-Wstringop-overflow=]
    8 |   foo (x + 1);
      |   ^
rh1948567-1.c:8:3: note: referencing argument 1 of type ‘char[2]’
rh1948567-2.c:2:1: note: in a call to function ‘foo’
    2 | foo (char x[2])
      | ^

Shouldn't the diagnostic pragma prevent the warning even in the LTO case?
Comment 1 Andrew Pinski 2022-11-30 16:41:43 UTC
(In reply to Jakub Jelinek from comment #0)
> Shouldn't the diagnostic pragma prevent the warning even in the LTO case?

Yes but I don't think it is streamed out. See PR 80922 (and a few others in the see also).

Confirmed.