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

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org


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: [hidden email]

        ReportedBy: [hidden email]





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
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org


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



Paolo Carlini <paolo.carlini at oracle dot com> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|ruboam at gmail dot com     |dodji at gcc dot gnu.org



--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-05 13:07:38 UTC ---

Maybe Dodji can have a look.
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org


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



Andrew Pinski <pinskia at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

           Keywords|                            |diagnostic

             Status|UNCONFIRMED                 |NEW

   Last reconfirmed|                            |2012-12-09

     Ever Confirmed|0                           |1



--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-09 00:31:40 UTC ---

Confirmed.  It only happens with the C++ front-end though.  The exact same code

does not warn with the C front-end.  I think this might be the pre-ahead of

time tokenizer that happens for the C++ front-end but does not happen for C.
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |federico.kircheis at gmail dot com

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
*** Bug 89718 has been marked as a duplicate of this bug. ***
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=53431

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Confirmed.  It only happens with the C++ front-end though.  The exact same
> code does not warn with the C front-end.  I think this might be the
> pre-ahead of time tokenizer that happens for the C++ front-end but does not
> happen for C.

so related to bug 53431 then
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=91669,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=90400,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=69558,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=9128

--- Comment #5 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Eric Gallager from comment #4)
> (In reply to Andrew Pinski from comment #2)
> > Confirmed.  It only happens with the C++ front-end though.  The exact same
> > code does not warn with the C front-end.  I think this might be the
> > pre-ahead of time tokenizer that happens for the C++ front-end but does not
> > happen for C.
>
> so related to bug 53431 then

and bug 91669, bug 90400, bug 69558, bug 91285, etc. We should probably choose
one of the bugs in this web of related bugs and choose one to use as the base
bug and mark the rest as duplicates, but idk which one...
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|https://gcc.gnu.org/bugzill |https://gcc.gnu.org/bugzill
                   |a/show_bug.cgi?id=9128      |a/show_bug.cgi?id=91285

--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
dang it, typoed one of the "See Also" entries...
Reply | Threaded
Open this post in threaded view
|

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

danglin at gcc dot gnu.org
In reply to this post by danglin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578

FeRD <ferdnyc at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ferdnyc at gmail dot com

--- Comment #7 from FeRD <ferdnyc at gmail dot com> ---
(In reply to Eric Gallager from comment #5)
> We should probably
> choose one of the bugs in this web of related bugs and choose one to use as
> the base bug and mark the rest as duplicates, but idk which one...

If you're taking votes from the "peanut gallery", I vote this one, as it's the
only one that even hints at a poorly-disseminated fact: That -no-integrated-cpp
serves as an easy workaround for this issue on affected versions, at the slight
expense of some additional compile time.

In our own CMake project, we've added the following config, to great effect:

#### Work around a GCC < 9 bug with handling of _Pragma() in macros
#### See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND
    (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "9.0.0"))
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-integrated-cpp")
endif()