[Bug c++/55578] New: Disabling warnings inside macro definition doesn't work

ruboam at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 3 18:41:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

             Bug #: 55578
           Summary: Disabling warnings inside macro definition doesn't
                    work
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ruboam@gmail.com


When compiling following code with just -Wall option I'm getting below
mentioned warning.

#define FF() \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
{int x;} \
_Pragma("GCC diagnostic pop")

int main()
{
  FF();
  return 0;
}

In function 'int main()':
warning: unused variable 'x' [-Wunused-variable]

But when I also specify -no-integrated-cpp or -save-temps options the warning
doesn't show up.

It looks like when preprocessor and compiler work in one shop the warning
doesn't get disabled. BTW this happens for any warning not just with
unused-variable one.

GCC version is: 4.6.2
Command line is: gcc <file-name> -Wall
System is: Linux  2.6.18-238.el5 #1 SMP Sun Dec 19 14:22:44 EST 2010 x86_64
x86_64 x86_64 GNU/Linux



More information about the Gcc-bugs mailing list