[Bug c++/68669] [5 regression] -Wunused-variable is not correctly supressed by #pragmas

trippels at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 3 12:03:00 GMT 2015


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

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
            Version|5.1.0                       |5.2.1
            Summary|-Wunused-variable is not    |[5 regression]
                   |correctly supressed by      |-Wunused-variable is not
                   |#pragmas                    |correctly supressed by
                   |                            |#pragmas

--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
markus@x4 tmp % cat run_tests.ii
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
class A {
public:
  static A &m_fn1();
};
namespace {
A &a = A::m_fn1();
}
#pragma GCC diagnostic pop

markus@x4 tmp % g++ -Wall -std=c++14 -O2 -c run_tests.ii
run_tests.ii:8:4: warning: ‘{anonymous}::a’ defined but not used
[-Wunused-variable]
 A &a = A::m_fn1();
    ^

gcc-6 doesn't warn at all (even without the "diagnostic ignored" pragma).


More information about the Gcc-bugs mailing list