Bug 1948567 - #pragma does not take an effect with -flto
Summary: #pragma does not take an effect with -flto
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 42
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-12 13:09 UTC by Kamil Dudka
Modified: 2025-02-26 12:51 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-05-21 14:11:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 107936 0 P3 UNCONFIRMED #pragma GCC diagnostic ignored vs. LTO 2022-11-30 16:07:34 UTC

Description Kamil Dudka 2021-04-12 13:09:25 UTC
Description of problem:
#pragma successfully suppresses a warning at compile time but the same warning then appears again at link time.


Version-Release number of selected component (if applicable):
gcc-11.0.1-0.4.fc35.x86_64


How reproducible:
100%


Steps to Reproduce:
1. prepare two source files:

$ cat main.c    
void foo(char x[2]);

int main() {
    char x[2];
#pragma GCC diagnostic ignored "-Wstringop-overflow"
    foo(x + 1);
}

$ cat foo.c     
void foo(char x[2])
{
    foo(x + 1);
}


2. compile/link without LTO:
$ gcc main.c foo.c


3. compile/link with LTO:
$ gcc -flto main.c foo.c


Actual results:
The warning is not suppressed if LTO is enabled:
main.c: In function ‘main’:
main.c:6:5: warning: ‘foo’ accessing 2 bytes in a region of size 1 [-Wstringop-overflow=]
    6 |     foo(x + 1);
      |     ^
main.c:6:5: note: referencing argument 1 of type ‘char *’
foo.c:1:6: note: in a call to function ‘foo’
    1 | void foo(char x[2])
      |      ^


Expected results:
The warning should be suppressed even when LTO is enabled.


Additional info:
Originally reported by Dmitry Belyavskiy (internal bug #1938797).

Comment 1 Ben Cotton 2021-08-10 12:58:40 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle.
Changing version to 35.

Comment 2 Ben Cotton 2022-11-29 16:55:17 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 3 Kamil Dudka 2022-11-30 13:44:40 UTC
This bug affects gcc-12.2.1-4.fc38.x86_64 as well.  The reproducer in comment #0 still works out of the box.

Comment 4 Ben Cotton 2023-02-07 14:51:57 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 5 Aoife Moloney 2024-05-07 15:43:32 UTC
This message is a reminder that Fedora Linux 38 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 38 on 2024-05-21.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '38'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 38 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 6 Aoife Moloney 2024-05-21 14:11:59 UTC
Fedora Linux 38 entered end-of-life (EOL) status on 2024-05-21.

Fedora Linux 38 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Kamil Dudka 2024-05-21 20:14:51 UTC
I can still reproduce the bug on Fedora Rawhide with gcc-14.1.1-1.fc41.x86_64.  So I am reopening the bug as advised in comment #6.

Comment 8 Aoife Moloney 2025-02-26 12:51:16 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.


Note You need to log in before you can comment on or make changes to this bug.