Bug 82711 - -Wignored-qualifiers could be moved into -Wextra
Summary: -Wignored-qualifiers could be moved into -Wextra
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 83085 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-10-25 07:52 UTC by Sylvestre Ledru
Modified: 2018-07-10 20:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvestre Ledru 2017-10-25 07:52:26 UTC
Compiling Firefox, we fixed several warnings found by -Wignored-qualifiers

I wonder if this option should not be moved under -Wextra.
The extra const isn't hurting and in a way improves readability.

Context: https://bugzilla.mozilla.org/show_bug.cgi?id=1411034
Comment 1 Jonathan Wakely 2017-10-25 10:49:26 UTC
I'd argue it doesn't help readability at all if it makes the code appear to do one thing but it actually does something different.

The warning has always been in -Wall for ignored qualifiers on return types, and nobody complained, so we don't want to change that. Maybe I should have added a separate option for ignoring qualifiers in casts. Intel ICC warns about return types in -Wall but needs -Wextra for the warning about the cast here:

const int f(long i)
{
  return static_cast<const int>(i);
}


1 : <source>(1): warning #858: type qualifier on return type is meaningless
  const int f(long i)
  ^
3 : <source>(3): warning #191: type qualifier is meaningless on cast type
    return static_cast<const int>(i);
                       ^
Compiler exited with result code 0


Alternatively, maybe the world's C++ code just needs to get fixed to stop writing things that have no meaning :-)
Comment 2 Jonathan Wakely 2017-11-21 10:10:24 UTC
*** Bug 83085 has been marked as a duplicate of this bug. ***
Comment 3 Sylvestre Ledru 2018-02-02 12:47:10 UTC
Jonathan, if I write a patch to implement the change, will you accept it?
Comment 4 nightstrike 2018-07-09 12:16:23 UTC
It looks to me like this has been done, at least for g++ 8.1.0:

$ g++ a.cc -c 
$ g++ a.cc -c -Wextra
a.cc:1:5: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
 int const f() { return 0; }
     ^~~~~
Comment 5 Martin Sebor 2018-07-10 16:30:27 UTC
-Wignored-qualifiers has been in -Wextra since r131499.  Based on the Firefox review I think the request is actually to remove the warning from -Wextra (or they thought it was in -Wall and were asking to move it from there and put it under -Wextra).
Comment 6 nightstrike 2018-07-10 16:42:55 UTC
(In reply to Martin Sebor from comment #5)
> -Wignored-qualifiers has been in -Wextra since r131499.  Based on the
> Firefox review I think the request is actually to remove the warning from
> -Wextra (or they thought it was in -Wall and were asking to move it from
> there and put it under -Wextra).

Maybe they compile with -Wextra and don't know it.... no idea.  However, comment 8 at https://bugzilla.mozilla.org/show_bug.cgi?id=1411034#c8 says:

"It should probably be enabled only in -Wextra"

Also, the title of the bug asks for it to be moved to -Wextra.  It's in there, so........   I think it's correct to just close the PR :) :) :)
Comment 7 Sylvestre Ledru 2018-07-10 16:47:35 UTC
Indeed, thanks for implementing the change!
Comment 8 Jonathan Wakely 2018-07-10 20:31:59 UTC
There was no change. r131499 was done more than a decade ago.