public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work
@ 2012-12-03 18:41 ruboam at gmail dot com
  2012-12-05 13:07 ` [Bug c++/55578] " paolo.carlini at oracle dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ruboam at gmail dot com @ 2012-12-03 18:41 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
@ 2012-12-05 13:07 ` paolo.carlini at oracle dot com
  2012-12-09  0:31 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-05 13:07 UTC (permalink / raw)
  To: gcc-bugs


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
  2012-12-05 13:07 ` [Bug c++/55578] " paolo.carlini at oracle dot com
@ 2012-12-09  0:31 ` pinskia at gcc dot gnu.org
  2021-04-26  9:34 ` vz-gcc at zeitlins dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-09  0:31 UTC (permalink / raw)
  To: gcc-bugs


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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
  2012-12-05 13:07 ` [Bug c++/55578] " paolo.carlini at oracle dot com
  2012-12-09  0:31 ` pinskia at gcc dot gnu.org
@ 2021-04-26  9:34 ` vz-gcc at zeitlins dot org
  2022-10-04  0:37 ` lhyatt at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vz-gcc at zeitlins dot org @ 2021-04-26  9:34 UTC (permalink / raw)
  To: gcc-bugs

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

Vadim Zeitlin <vz-gcc at zeitlins dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vz-gcc at zeitlins dot org

--- Comment #8 from Vadim Zeitlin <vz-gcc at zeitlins dot org> ---
For the record: with gcc 11 this bug now affects the existing code using
pragmas to locally suppress -Wsuggest-override, i.e. the warning is not
suppressed any longer, even though it used to work in all versions since gcc 5,
so not only this bug is still present, but it got worse in the latest version.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
                   ` (2 preceding siblings ...)
  2021-04-26  9:34 ` vz-gcc at zeitlins dot org
@ 2022-10-04  0:37 ` lhyatt at gcc dot gnu.org
  2022-10-04 16:04 ` vz-gcc at zeitlins dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-10-04  0:37 UTC (permalink / raw)
  To: gcc-bugs

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

Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lhyatt at gcc dot gnu.org

--- Comment #9 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
This was fixed by r9-1926 (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69558#c25) and is a dupe of that
aspect of PR69558. I would suggest to mark this one resolved, however comment 8
brought up that there was potentially a change in behavior in GCC 11. Do you
have an example test case that doesn't behave as you expect? If not, I would
suggest to close this one, there has been a lot of progress on pragma locations
and I believe most such issues are now fixed on GCC 13 master branch.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
                   ` (3 preceding siblings ...)
  2022-10-04  0:37 ` lhyatt at gcc dot gnu.org
@ 2022-10-04 16:04 ` vz-gcc at zeitlins dot org
  2022-10-05 22:08 ` lhyatt at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vz-gcc at zeitlins dot org @ 2022-10-04 16:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Vadim Zeitlin <vz-gcc at zeitlins dot org> ---
There definitely was a change in behaviour in gcc 11 because I had to make this
change

https://github.com/wxWidgets/wxWidgets/commit/95c98a0b5ff71caca6654327bf341719c6587766

to avoid getting warnings with it that we didn't get with the previous
versions.

The idea there is that we define some macros whose expansion contains
declarations of overridden virtual functions, which inevitably results in
-Wsuggest-override when used in user classes using or not using "override" for
their other functions, so we have to disable this warning locally.
wxWARNING_SUPPRESS_MISSING_OVERRIDE, which expands to

    _Pragma("GCC diagnostic push")
    _Pragma("GCC diagnostic ignored \"-Wsuggest-override\"")

worked for this until gcc 11 but not with it.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
                   ` (4 preceding siblings ...)
  2022-10-04 16:04 ` vz-gcc at zeitlins dot org
@ 2022-10-05 22:08 ` lhyatt at gcc dot gnu.org
  2022-10-06  1:31 ` vz-gcc at zeitlins dot org
  2022-10-06  1:58 ` lhyatt at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-10-05 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
(In reply to Vadim Zeitlin from comment #10)
> There definitely was a change in behaviour in gcc 11 because I had to make
> this change
> 
> https://github.com/wxWidgets/wxWidgets/commit/
> 95c98a0b5ff71caca6654327bf341719c6587766

Thanks for that. I made a bisectable test that compiles allheaders.cpp (without
your GCC 11-specific workaround in place) and counts the number of
-Wsuggest-override warnings, which does indeed change in GCC 11.1 vs older and
newer versions. The bisect confirmed that this issue was the same as that of
PR100796. It existed only in GCC 11.1, as it was introduced by r11-7179 and was
fixed by r12-1538, which was also backported to GCC 11.2.

This particular issue only materializes with a sufficiently large source file,
so I don't think you should find any "reasonably" sized testcase to reproduce
it. All basic examples I tried work fine in 11.1 as well. As far as I can tell,
I think your workaround should be needed only for sufficiently large
translation units (approx 100000 lines or more), not for typical size user
code, and I think it should be needed only for 11.1 and no other version. If
you know otherwise, please advise... otherwise, I think this is resolved.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
                   ` (5 preceding siblings ...)
  2022-10-05 22:08 ` lhyatt at gcc dot gnu.org
@ 2022-10-06  1:31 ` vz-gcc at zeitlins dot org
  2022-10-06  1:58 ` lhyatt at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vz-gcc at zeitlins dot org @ 2022-10-06  1:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Vadim Zeitlin <vz-gcc at zeitlins dot org> ---
Thanks for looking at this! I'm happy to hear that the problem is fixed in
11.2, but I'm probably not going to change our code anyhow, especially as we're
going to finally drop support for C++98 very soon and so will be able to just
use "override" unconditionally anyhow.

I.e. from my point of view there is no real problem any more, I just replied
here to give more information about the problem in case it could be useful.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/55578] Disabling warnings inside macro definition doesn't work
  2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
                   ` (6 preceding siblings ...)
  2022-10-06  1:31 ` vz-gcc at zeitlins dot org
@ 2022-10-06  1:58 ` lhyatt at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2022-10-06  1:58 UTC (permalink / raw)
  To: gcc-bugs

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

Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #13 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
(In reply to Vadim Zeitlin from comment #12)
> Thanks for looking at this! I'm happy to hear that the problem is fixed in
> 11.2, but I'm probably not going to change our code anyhow, especially as
> we're going to finally drop support for C++98 very soon and so will be able
> to just use "override" unconditionally anyhow.
> 
> I.e. from my point of view there is no real problem any more, I just replied
> here to give more information about the problem in case it could be useful.

Thanks, yes it was useful. Hopefully, issues with warning suppression will be
increasingly rare going forward.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-06  1:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-03 18:41 [Bug c++/55578] New: Disabling warnings inside macro definition doesn't work ruboam at gmail dot com
2012-12-05 13:07 ` [Bug c++/55578] " paolo.carlini at oracle dot com
2012-12-09  0:31 ` pinskia at gcc dot gnu.org
2021-04-26  9:34 ` vz-gcc at zeitlins dot org
2022-10-04  0:37 ` lhyatt at gcc dot gnu.org
2022-10-04 16:04 ` vz-gcc at zeitlins dot org
2022-10-05 22:08 ` lhyatt at gcc dot gnu.org
2022-10-06  1:31 ` vz-gcc at zeitlins dot org
2022-10-06  1:58 ` lhyatt at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).