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

            Bug ID: 111918
           Summary: #pragma GCC diagnostic pop does not restore permerror
                    status of -Wnarrowing
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
                CC: dmalcolm at gcc dot gnu.org, jason at gcc dot gnu.org
  Target Milestone: ---

Consider this test case:

float f1{123456789};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnarrowing"
float f2{123456789};
#pragma GCC diagnostic pop
float f3{123456789};

It reports (with GCC 13.2 and trunk):

t.cc:1:10: error: narrowing conversion of ‘123456789’ from ‘int’ to ‘float’
[-Wnarrowing]
    1 | float f1{123456789};
      |          ^~~~~~~~~
t.cc:6:10: warning: narrowing conversion of ‘123456789’ from ‘int’ to ‘float’
[-Wnarrowing]
    6 | float f3{123456789};
      |          ^~~~~~~~~

I would have expected an error at line 6 because the original diagnostics state
should have been restored by the pop pragma.

This might be a more generic issue, not specific to -Wnarrowing.  I see it with
newly added permerrors in the C front end, too.

Reply via email to