Summary: | -Wignored-qualifiers could be moved into -Wextra | ||
---|---|---|---|
Product: | gcc | Reporter: | Sylvestre Ledru <sylvestre> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | CC: | msebor, nightstrike, webrown.cpp |
Priority: | P3 | Keywords: | diagnostic |
Version: | 8.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: |
Description
Sylvestre Ledru
2017-10-25 07:52: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 :-) *** Bug 83085 has been marked as a duplicate of this bug. *** Jonathan, if I write a patch to implement the change, will you accept it? 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; } ^~~~~ -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). (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 :) :) :) Indeed, thanks for implementing the change! |