https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123287

            Bug ID: 123287
           Summary: Suppressed warning is disabled when used in
                    precompiled header
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gast128 at hotmail dot com
  Target Milestone: ---

Hello all,

we are porting some code to Linux. In our current situation some warnings were
suppressed in a precompiled header but this doesn't seem to work anymore with
GCC 14.2.0. If in a pch a warning is suppressed the warning still seems to pop
up in the cpp file despite inclusion of the header (and pch).

Example:

// test_pch.h:
#pragma once
#pragma GCC diagnostic ignored "-Wunused-variable"

// test_pch.cpp:
#include "test_pch.h"

int main()
{
    int a = 0;  // -Wunused-variable but suppressed in header

    return 0;
}

now:
g++ -Wall test_pch.cpp

This is fine; warning is suppressed. 

But with:
g++ -Wall test_pch.h
g++ -Wall test_pch.cpp

The suppression is not enabled anymore for cpp:
test_pch.cpp:5:9: warning: unused variable ‘a’ [-Wunused-variable]
    5 |     int a = 0;

Reply via email to